The Minimum Path Sum problem asks you to find the path from the top-left to the bottom-right corner of a grid that minimizes the sum of all cell values along the way. You can only move right or down at each step. Despite its simple statement, the Minimum Path Sum coding problem is a foundational dynamic programming exercise that underpins dozens of related grid DP problems seen in real interviews.
This is one of the most commonly asked questions by top-tier companies including Apple, Google, Microsoft, Amazon, Meta, Goldman Sachs, and Bloomberg. It cleanly tests bottom-up DP intuition and in-place optimization. Interviewers use it as a gateway problem — if a candidate stumbles on Minimum Path Sum, it signals gaps in DP fundamentals. The array, matrix, and dynamic programming interview pattern is perfectly embodied here.
The approach is classic 2D dynamic programming. Define dp[i][j] as the minimum sum to reach cell (i, j). Recurrence: dp[i][j] = grid[i][j] + min(dp[i-1][j], dp[i][j-1]). Base cases handle the first row (only left-to-right moves) and first column (only top-to-bottom moves). Space can be optimized to O(n) by using a 1D DP array, updating it as you scan each row.
Grid:
1 3 1
1 5 1
4 2 1
DP fills in:
The minimum path sum is 7, following the path: 1→3→1→1→1.
Minimum Path Sum is your entry point into grid DP. Master the 2D DP transition, then practice the O(n) space optimization. Once comfortable, extend your skills to problems with obstacles, multiple starting points, or diagonal moves. Being able to derive the recurrence on a whiteboard without hesitation is a hallmark of strong DP fundamentals — the exact signal interviewers look for.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Unique Paths II | Medium | Solve | |
| Minimum Falling Path Sum | Medium | Solve | |
| Maximal Square | Medium | Solve | |
| Count Square Submatrices with All Ones | Medium | Solve | |
| Maximum Number of Points with Cost | Medium | Solve |