Easy DP solution || Bigenner Friendly || Easy to UnderStand
Approach\n1. Explore All 3 paths\n2. Find max of all 3 paths and store it in a dp\n\n# Complexity\n- Time complexity:O(N(M+N))\n\n- Space complexity:O(NM)\n\n# 
# Approach\n1. Explore All 3 paths\n2. Find max of all 3 paths and store it in a dp\n\n# Complexity\n- Time complexity:O(N*(M+N))\n\n- Space complexity:O(N*M)\n\n# Code\n```\nclass Solution {\npublic:\n    int f(int i,int j,int n,int m, vector<vector<int>>& grid,vector<vector<int>>&dp){\n        if(i<0 || i>=n || j>=m)return 0;\n        if(dp[i][j] != -1)return dp[i][j];\n        int path1 = 0,path2 = 0,path3 = 0;\n        if(i > 0 and j < m-1 and grid[i][j] < grid[i-1][j+1]){\n            path1 = 1+f(i-1,j+1,n,m,grid,dp);\n        }\n        if(j < m-1 and grid[i][j] < grid[i][j+1]){\n            path2 = 1+f(i,j+1,n,m,grid,dp);\n        }\n        if(i < n-1 and j < m-1 and grid[i][j] < grid[i+1][j+1]){\n            path3 = 1+f(i+1,j+1,n,m,grid,dp);\n        }\n        return dp[i][j] = max(path1,max(path2, path3));\n    }\n    int maxMoves(vector<vector<int>>& grid) {\n        int n = grid.size();\n        int m = grid[0].size();\n        int ans = 0;\n        vector dp(n+1,vector<int>(m+1,-1));\n        for(int i=0;i<n;i++){  \n            int temp = f(i,0,n,m,grid,dp);\n            ans = max(ans,temp);\n        }\n        return ans;\n    }\n};\n```\n*Hope it will help you*\n\n
['Array', 'Dynamic Programming', 'Matrix', 'C++']