Data Structures & AlgorithmsHardTCS NQT · Accenture

Problem: A grid of 3 rows and 3 columns is filled with the numbers 1 to 9 row by row. A "line" is a complete row, column or main diagonal. How many lines have a sum greater than 14?

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

Correct answer: B. 6

Line sums: rows 6, 15, 24; columns 12, 15, 18; diagonals 15, 15, so six exceed 14. Ignoring the diagonals gives 4, counting every line gives 8, and using only one diagonal gives 5.

More Coding Interview Problems questions

Exams that ask this topic