Easy Dynamic programming || Memoization
\nclass Solution:\n    def maxMoves(self, grid: List[List[int]]) -> int:\n        \n        def helper(row,col) :\n            \n            if row < 0 or row >
```\nclass Solution:\n    def maxMoves(self, grid: List[List[int]]) -> int:\n        \n        def helper(row,col) :\n            \n            if row < 0 or row >= m or col >= n:\n                return 0\n            \n            if dp[row][col] != -1:\n                return dp[row][col]\n            \n            directions = [(row - 1, col + 1), (row, col + 1), (row + 1, col + 1) ]\n            \n            max_moves = 0\n            \n            for x,y in directions :\n                \n                if x>=0 and x < m and (y < n) and grid[x][y] > grid[row][col] :\n                    \n                    if dp[x][y] != -1:\n                        max_moves = max(max_moves , 1+dp[x][y])\n                        \n                    else :\n                        max_moves = max(max_moves , 1+helper(x,y))\n                        \n            dp[row][col] = max_moves\n            return dp[row][col]\n        \n        \n        \n        m = len(grid)\n        n = len(grid[0])\n        \n        ans = 0\n        \n        dp = [[-1 for i in range(n)]for j in range(m)]\n\n        dp[m-1][n-1] = 0\n        \n        for i in range(m):\n            ans = max(ans , helper(i,0))\n            \n        return ans\n                \n```
['Dynamic Programming', 'Memoization', 'Python', 'Python3']