C++ | DFS | Without DP | Easy
\nclass Solution {\n    int dfs(int n, int m, vector<vector<int>>& grid, int i, int j, int prev) {\n        if(i < 0 or j < 0 or i >= n or j >= m or grid[i][j] 
```\nclass Solution {\n    int dfs(int n, int m, vector<vector<int>>& grid, int i, int j, int prev) {\n        if(i < 0 or j < 0 or i >= n or j >= m or grid[i][j] <= prev)return 0;\n        \n        int val = grid[i][j];\n        grid[i][j] = 0;\n        \n        int ans = max({dfs(n,m,grid,i-1,j+1,val), dfs(n,m,grid,i,j+1,val),dfs(n,m,grid,i+1,j+1,val)}) + 1;\n        \n        return ans;\n    }\npublic:\n    int maxMoves(vector<vector<int>>& grid) {\n        int n = size(grid), m = size(grid[0]), res = 0;\n        \n        for(int i = 0; i < n; i++) {\n            res = max(res,dfs(n,m,grid,i,0,-1e6));\n        }\n        \n        return res - 1;\n    }\n};\n```
['Depth-First Search', 'C', 'C++']