Minimum-cost path through a grid
You're given a grid of tolls. Starting at the top-left cell and moving only right or down, reach the bottom-right cell, paying the value of every cell you pass through.
grid = [[1, 3, 1],
[1, 5, 1],
[4, 2, 1]]
-> 7 # path 1 -> 3 -> 1 -> 1 -> 1
Return the minimum total toll. Aim for .
Show a hint
Every path into a cell arrives from the left or from above. The cheapest way into a cell is its own toll plus the cheaper of those two predecessors.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.