Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: A grid of size 3×4 has the cell values 1 to 12 filled row-wise. Starting at the top-left (value 1), you may move right or down only, and you collect the value of every cell you enter. What is the maximum possible sum of collected values to reach the bottom-right cell?

  1. A. 30
  2. B. 48
  3. C. 47
  4. D. 78

Correct answer: B. 48

Larger values lie lower and to the right, so go down first: 1 → 5 → 9 → 10 → 11 → 12 = 48 (a right/down DP confirms it). Going right first gives the minimum 30, leaving out the start cell gives 47, and 78 adds every cell.

More Coding Interview Problems questions

Exams that ask this topic