Very easy to understand Java Solution using DFS+DP(Recursive Solution)
\n\n# Complexity\n- Time complexity:\nO(nm)\n\n- Space complexity:\nO(nm)\n\n# Code\njava []\nclass Solution {\n    public int maxMoves(int[][] grid) {\n       
\n\n# Complexity\n- Time complexity:\nO(n*m)\n\n- Space complexity:\nO(n*m)\n\n# Code\n```java []\nclass Solution {\n    public int maxMoves(int[][] grid) {\n        // you can move to (row-1 col+1 ) (row,col+1) (row+1,col+1)\n        // value should be bigger than the previous cell\n        int max = 0;\n        int[][] dp = new int[grid.length][grid[0].length];\n        for(int[] a:dp)Arrays.fill(a,-1);\n\n        for(int row = 0;row<grid.length;row++){\n            max = Math.max(max,help(grid,row,0,dp));\n        }\n        return max;\n    }\n    public static int help(int[][] grid,int row,int col,int[][] dp){\n        int[][] directions = new int[][]{{1,1},{-1,1},{0,1}};\n        if(dp[row][col] != -1)return dp[row][col];\n        int temp = grid[row][col];\n        grid[row][col] = -1;\n        int maxAns = 0;\n        for(int i =0;i<directions.length;i++){\n            int ans = 0;\n            int newRow = row+directions[i][0];\n            int newCol = col+directions[i][1];\n\n            if(check(grid,newRow,newCol,temp)){\n                ans++;\n                ans += help(grid,newRow,newCol,dp);\n            }\n            maxAns = Math.max(ans,maxAns);\n        }\n        grid[row][col] = temp;\n        return dp[row][col] = maxAns;\n    }\n\n    public static boolean check(int[][] grid,int row,int col,int prev){\n        if(row<grid.length && row>=0 && col>=0 && col<grid[0].length && grid[row][col] != -1 && grid[row][col]>prev){\n            return true;\n        }\n        return false;\n    }\n}\n```
['Dynamic Programming', 'Depth-First Search', 'Matrix', 'Java']