python simple dynamic programming
Intuition\nlooking at this problem we can say that it can be solved using dynamic programming\n# Approach\n Describe your approach to solving the problem. \n\n\
# Intuition\nlooking at this problem we can say that it can be solved using dynamic programming\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n\n# Complexity\n- Time complexity:\nO(n*m)\n- Space complexity:\nO(n*m)\n\n# Code\n```\nclass Solution:\n    def maxMoves(self, grid: List[List[int]]) -> int:\n        dp={}\n        def dfs(i,j):\n            n=0\n            n1=0\n            n2=0\n            if((i,j) in dp):return dp[(i,j)]\n            if(i-1>=0 and j+1<len(grid[0]) and grid[i][j]<grid[i-1][j+1]):\n                n=1+dfs(i-1,j+1)\n            if(i>=0 and i<len(grid) and j+1<len(grid[0])):\n                if(i+1<len(grid) and grid[i+1][j+1]>grid[i][j]):\n                    n1=1+dfs(i+1,j+1)\n                if(grid[i][j+1]>grid[i][j]):\n                    n2=1+dfs(i,j+1)\n            dp[(i,j)]=max(n,n1,n2)\n            return dp[(i,j)]\n        res=0\n        for i in range(len(grid)):\n            res=max(res,dfs(i,0))\n        return res\n```
['Python3']