Approach hintTry it first, then revealHide
Let dp[i][j] be the cheapest cost to reach cell (i, j); it extends the better of the cell above and the cell to the left. A single rolling row reduces memory to O(n).
Let dp[i][j] be the cheapest cost to reach cell (i, j); it extends the better of the cell above and the cell to the left. A single rolling row reduces memory to O(n).