DP Solution - JAVA 100% Beats
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    int memo[][];\n    public int maxMoves(int[][] grid) {\n        memo=new int[grid.length+1][grid[0].length+1];\n        int max=0;\n        for(int i=0;i<memo.length;i++)\n        {\n            for(int j=0;j<memo[0].length;j++)\n                memo[i][j]=-1;\n        }\n        for(int i=0;i<grid.length;i++)\n        {\n            max=Math.max(max,maxMove(i,0,grid));\n        }\n        return max;\n    }\n    public int maxMove(int i,int j,int a[][])\n    {\n        if(memo[i][j]==-1)\n        {\n            if(j==a[0].length-1)\n            return 0;\n        \n            int x=0,y=0,z=0;\n            if(i!=0&&a[i-1][j+1]>a[i][j])\n                x = 1+maxMove(i-1,j+1,a);\n\n            if(a[i][j+1]>a[i][j])\n                y = 1+maxMove(i,j+1,a);\n\n            if(i!=a.length-1&&a[i+1][j+1]>a[i][j])\n                z = 1+maxMove(i+1,j+1,a);\n\n            memo[i][j] = Math.max(z,Math.max(x,y));    \n        }\n        return memo[i][j];\n    }\n}\n```
['Java']