Data Structures & AlgorithmsHardProduct Company SDE · ICPC regional
Problem: A 3×3 matrix is [[2,1,3],[6,5,4],[7,8,9]]. A falling path moves from a cell in row r to a cell in row r+1 in the same column or one column to the left or right. What is the minimum sum of a falling path that starts in row 0 and ends in row 2?
- A. 17
- B. 14
- C. 12
- D. 13
Correct answer: D. 13
Row by row, each cell adds the minimum of its up-to-three parents: the best paths are 1 → 4 → 8 or 1 → 5 → 7 = 13. Using max gives 17, staying in one column gives 1 + 5 + 8 = 14, and adding the row minima while ignoring adjacency gives 1 + 4 + 7 = 12.
More Coding Interview Problems questions
- Problem: Video clips of the form [start, end] cover the interval [0, 10]. The clips are [0,2], [4,6], [8,10], [1,9], [2,5], [5,7]. What is…
- Problem: The stock span of a day is the number of consecutive days (including today) up to and including today with a price at most…
- Problem: Five customers with service times 5, 3, 8, 2, 4 (in arrival order) are served by two tellers. Each customer goes to whichever…
- Problem: How many ordered pairs (a, b) of positive integers satisfy a × b = 36 with a ≤ 100 and b ≤ 100?
- Problem: How many non-negative integer solutions (x, y, z) satisfy x + y + z = 10?
- Problem: How many integer solutions (x, y, z) with x, y, z ≥ 1 satisfy x + y + z = 10?