Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: Find the minimum path sum from the top to the bottom of the triangle [[2], [3, 4], [6, 5, 7], [4, 1, 8, 3]], moving to an adjacent entry in the next row at each step.

  1. A. 21
  2. B. 15
  3. C. 11
  4. D. 16

Correct answer: C. 11

Bottom-up, each entry adds the smaller of its two children: the best path is 2 → 3 → 5 → 1 = 11. Using max instead of min gives 21, always going straight down the left edge gives 15, and a top-down DP that reads the last bottom cell instead of the row minimum gives 16.

More Coding Interview Problems questions

Exams that ask this topic