Solution of Problem No.2684. Maximum Number of Moves in a Grid
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python []\nclass Solution:\n    def maxMoves(self, grid):\n        m, n = len(grid), len(grid[0])\n        dp = [[0] * n for _ in range(m)]\n\n        for j in range(n - 1, -1, -1):\n            for i in range(m):\n                for di, dj in [(-1, 1), (0, 1), (1, 1)]:\n                    ni, nj = i + di, j + dj\n                    if 0 <= ni < m and 0 <= nj < n and grid[ni][nj] > grid[i][j]:\n                        dp[i][j] = max(dp[i][j], 1 + dp[ni][nj])\n\n        return max(dp[i][0] for i in range(m))\n```
['Python']