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?

  1. A. 9
  2. B. 5
  3. C. 8
  4. 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

Exams that ask this topic