[Python 3] Simple Dynamic Programming
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```\nclass Solution:\n    def maxMoves(self, grid: List[List[int]]) -> int:\n        m, n = len(grid), len(grid[0])\n        @cache\n        def dp(i: int, j: int) -> int:\n            if i < 0 or i >= m or j < 0 or j >= n: return 0\n            res = 0 \n            cur = grid[i][j]\n            for x, y in [(-1, 1), (0, 1), (1, 1)]:\n                if 0 <= i + x < m and 0 <= j + y < n and grid[i + x][j + y] > cur:\n                    res = max(res, dp(i + x, j + y) + 1)\n            return res\n        ans = 0\n        for i in range(m):\n            ans = max(ans, dp(i, 0))\n        return ans\n```
['Dynamic Programming', 'Matrix', 'Python3']