m × n matrix field of positive numbers. You may start at any cell of the first (leftmost) column.
From cell (r, c) you can move to one of the cells in the next column: (r - 1, c + 1), (r, c + 1) or (r + 1, c + 1), but only if the new cell holds a strictly larger number than the current one.
Return the largest number of moves you can make.field=[[1, 6, 2, 9], [4, 3, 7, 8], [2, 5, 1, 3]] → 3
Start at the 1 in the top-left corner: 1 → 6 → 7 → 9 (right, down-right, up-right), three moves to the right edge.
field=[[5, 4], [6, 2]] → 0
Both numbers in the second column are smaller than anything in the first, so no move is possible.
field=[[3, 4, 1], [9, 9, 9]] → 2
m, n ≤ 1000m · n ≤ 10⁵field[i][j] ≤ 10⁶field=[[1, 6, 2, 9], [4, 3, 7, 8], [2, 5, 1, 3]]
3
Run checks the first 3 tests in your browser. Submit checks all 84 tests on the server, hidden ones included.