CPP | Dfs
\nclass Solution {\npublic:\n    int dp[1001][1001];\n    int dfs(vector<vector<int>> &v,int i,int j,int prev) {\n        if(i < 0 || i >= v.size() || j >= v[0]
```\nclass Solution {\npublic:\n    int dp[1001][1001];\n    int dfs(vector<vector<int>> &v,int i,int j,int prev) {\n        if(i < 0 || i >= v.size() || j >= v[0].size() || v[i][j] <= prev) return -1;\n        if(dp[i][j] != -1) return dp[i][j];\n        return dp[i][j] = max({1 + dfs(v,i - 1,j + 1,v[i][j]),1 + dfs(v,i,j + 1,v[i][j]), 1 + dfs(v,i + 1,j + 1,v[i][j])});\n    }\n    int maxMoves(vector<vector<int>>& grid) {\n        int ans = 0;\n        memset(dp,-1,sizeof(dp));\n        for(int j = 0; j < grid.size(); j += 1) {\n            ans = max(ans,dfs(grid,j,0,-1));\n            \n        }\n        return ans;\n    }\n};\n```
['C++']