Data Structures & AlgorithmsHardTCS NQT · Accenture

In a 3 by 3 grid with no walls, how many cells are exactly 2 moves (up, down, left or right) away from the top-left corner?

  1. A. 4
  2. B. 5
  3. C. 3
  4. D. 7

Correct answer: C. 3

The cells at Manhattan distance 2 are (0,2), (1,1) and (2,0), so the count is 3.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic