m × n integer grid grid. You may start in any cell. In one move you can jump to **any** other cell in the same row or the same column (not necessarily adjacent), as long as its value is strictly greater than the current one.
Keep moving for as long as you can. Return the largest number of cells a single route can visit, counting the starting cell.grid=[[3, 8, 4], [1, 6, 9]] → 4
For example 1 → 3 (up the column) → 4 (along the row) → 9 (down the column): four cells. Five is out of reach.
grid=[[5, 5], [5, 5]] → 1
All values are equal and moves need a strictly larger value, so a route is a single cell.
grid=[[3, 8, 4], [1, 6, 9]]
4
Run checks the first 3 tests in your browser. Submit checks all 108 tests on the server, hidden ones included.