board of integers. A descent picks exactly one number in every row, top to bottom, such that the picks from any two neighbouring rows are never in the same column.
Return the smallest possible sum of a descent.board=[[2, 9, 4], [5, 1, 8], [6, 3, 7]] → 9
Picking 2, 1, 3 is tempting, but 1 and 3 share a column. The best is 2, 1, 6, summing to 9; 2, 1, 7 would give 10.
board=[[-5, 0], [-4, 3]] → -4
-5 and -4 sit in the same column, so it's either -5 and 3 (sum -2) or 0 and -4 (sum -4). The answer is -4.
board=[[42]] → 42
board is an n × n tableboard=[[2, 9, 4], [5, 1, 8], [6, 3, 7]]
9
Run checks the first 3 tests in your browser. Submit checks all 65 tests on the server, hidden ones included.