Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: A 3×3 spiral is filled starting with 1 at the top-left and moving right, then down, then left, then up, spiralling inward. What is the value at the centre cell?
- A. 9
- B. 5
- C. 8
- D. 4
Correct answer: A. 9
The outer ring takes 1..8 and the spiral ends at the centre with 9. Row-major filling would put 5 there, 8 is the last ring cell, and 4 sits just right of the centre.
More Coding Interview Problems questions
- Problem: Count the unordered pairs (x, y) with 1 ≤ x < y ≤ 7 for which x OR y equals 7.
- Problem: In base 8, how many trailing zeros does 100! have?
- Problem: What is the sum of the divisors of 360 that are perfect squares?
- Problem: How many integers from 1 to 200 are both perfect squares and perfect cubes?
- Problem: Compute 7^2024 modulo 9.
- Problem: What is the multiplicative inverse of 3 modulo 11 (the value x with 0 ≤ x < 11 and 3x ≡ 1 mod 11)?