DP + BFS. Simple solutions. Runtime 100%
\nclass Solution:\n    def maxMoves(self, grid: List[List[int]]) -> int:\n        m, n = len(grid), len(grid[0])\n        dp = [True] * m\n        for c in rang
```\nclass Solution:\n    def maxMoves(self, grid: List[List[int]]) -> int:\n        m, n = len(grid), len(grid[0])\n        dp = [True] * m\n        for c in range(1, n):\n            new_dp, is_available = [], False\n            for r in range(m):\n                for rr in (r-1, r, r+1):\n                    if 0 <= rr < m and dp[rr] and grid[rr][c-1] < grid[r][c]:\n                        new_dp.append(True)\n                        is_available = True\n                        break\n                else:\n                    new_dp.append(False)\n            if not is_available:\n                return c-1\n            dp = new_dp\n        return n-1 \n``` \n```\nclass Solution:\n    def maxMoves(self, grid: List[List[int]]) -> int:\n        m, n = len(grid), len(grid[0])\n        stack = {*range(m)}\n        for c in range(1, n):\n            new_stack = set()\n            while stack:\n                r = stack.pop()\n                for rr in (r-1, r, r+1):\n                    if 0 <= rr < m and grid[r][c-1] < grid[rr][c]:        \n                        new_stack.add(rr)\n            if not new_stack:\n                return c-1\n            stack = new_stack\n        return n-1\n```
['Dynamic Programming', 'Python3']