Minimum Path Sum
Recognize the pattern
Brute force idea
The naive version of Minimum Path Sum sounds like this: Try all paths. Each cell branches into right and down. That direct path helps you understand the question, but it tends to treat every possibility as brand new instead of learning from earlier steps.
Better approach
The deeper shift in Minimum Path Sum is this: DP: dp[i][j] = grid[i][j] + min(dp[i-1][j], dp[i][j-1]). Each cell's minimum cost comes from the cheaper of the cell above or to the left., and you can compress the memory down even further. Once you hold onto the right piece of information from moment to moment, the problem feels less like trial and error and more like following a shape that was there all along.
Key invariant
At the center of Minimum Path Sum is one steady idea: You can only arrive from above or the left. The minimum cost to reach (i,j) is its own cost plus the cheaper of the two possible predecessors. No other path can be cheaper. When you keep that truth intact, each local choice supports the larger solution instead of fighting it.
Watch out for
One easy way to drift off course in Minimum Path Sum is this: Not initializing the first row and column correctly — the first row can only come from the left, and the first column only from above. They have only one predecessor each. The fix is usually to return to the meaning of each move, not just the steps themselves.