grid of integers. You walk down it from top to bottom: start in any cell of the first row, and at each step move to the next row, either straight down or one column diagonally. From cell (r, c) you can go to (r + 1, c - 1), (r + 1, c) or (r + 1, c + 1), as long as that cell exists.
The cost of a descent is the sum of all cells it visits, from the first row to the last. Return the minimum possible cost.grid=[[4, 9, 1], [3, 2, 8], [6, 5, 7]] → 8
The cheapest way down is 1 → 2 → 5, for a total of 8.
grid=[[5, -3], [-8, 10]] → -11
From -3 you can step diagonally onto -8, giving -11.
grid=[[42]] → 42
grid=[[4, 9, 1], [3, 2, 8], [6, 5, 7]]
8
Run checks the first 3 tests in your browser. Submit checks all 69 tests on the server, hidden ones included.