Data Structures & AlgorithmsModerateTCS NQT · CAT

Problem: On a 3×3 grid, each cell is labelled with its row times column (1-indexed). The number of cells whose label is a perfect square is what value?

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

Correct answer: D. 3

The labels are the products r·c for r, c in 1 to 3. The perfect-square labels are 1, 4 and 9, which occur at (1,1), (2,2) and (3,3), so the count is 3.

More Coding Interview Problems questions

Exams that ask this topic