Data Structures & AlgorithmsModerateTCS NQT Digital · Accenture

Problem: A grid of 4×4 cells holds the value r + c (0-indexed). Starting from the top-left corner, what is the maximum total of values along a path that moves only right or down to the bottom-right corner (both endpoints included)?

  1. A. 15
  2. B. 35
  3. C. 48
  4. D. 21

Correct answer: D. 21

Every right/down path visits exactly one cell on each anti-diagonal r + c = k for k = 0..6, so every path totals 0 + 1 + … + 6 = 21 and the DP max is also 21. Dropping the end cell gives 15, using 1-indexed values gives 35, and 48 is the sum of the whole grid.

More Coding Interview Problems questions

Exams that ask this topic