Solved LeetCode program · 697 of 1,000
#0931 · Minimum Falling Path Sum
Original English source
The cells is a list of 2, 1, 3, 6, 5, 4, 7, 8, and 9. The width is 3, while the height is 3. The table is a list of 9 zeros.
For every column from 0 to 2.
Set item column of table to item column of cells.
For every level from 1 to height minus 1.
For every column from 0 to width minus 1.
The index is (level times width) plus column. The above is index minus width. The best is item above of table. If column is more than 0, set best to the smaller of best and item (above minus 1) of table. If column is less than width minus 1, set best to the smaller of best and item (above plus 1) of table. Set item index of table to best plus item index of cells.
The last is the last position of table. The answer is item (last minus 2) of table.
For every column from 1 to 2.
The candidate is item (last minus 2 plus column) of table. If candidate is less than answer, set answer to candidate.
Show answer.
Expected stdout
13