Python || BFS || O(m*n)
From left to right, for each column, save the row_indices of reachable cells in dq.\n2. Row_indices of reachable cells in the next column are saved in nxt. If n
1. From left to right, for each column, save the row_indices of reachable cells in `dq`.\n2. Row_indices of reachable cells in the next column are saved in `nxt`. If `nxt` is nonempty, we can move to the next column, hence add 1 to `moves`.\n```\nclass Solution:\n    def maxMoves(self, grid: List[List[int]]) -> int:\n        m, n = len(grid), len(grid[0])\n        dq = deque(range(m))\n        moves = 0\n        while dq and moves < n-1:\n            nxt = set()\n            for _ in range(len(dq)):\n                idx = dq.popleft()\n                val = grid[idx][moves]\n                for i in range(max(0, idx-1), min(m, idx+2)):\n                    if grid[i][moves+1] > val:\n                        nxt.add(i)\n            if len(nxt) > 0:\n                moves += 1\n            dq.extend(nxt)\n        return moves\n
['Python3']