C++ | Recursive DP
Code
# Code
```cpp []
class Solution {
public:
    vector<vector<vector<int>>>dp;
    int m,n;
    int find(int i,int j, int power, vector<vector<int>>& coins)
    {
        if(i==m-1 && j==n-1)
        {
            if(coins[i][j]>=0 || power==0)
               return coins[i][j];
            return 0;      
        }
        if(dp[i][j][power]!=INT_MIN)
           return dp[i][j][power];
        int res=INT_MIN;
        if(i+1<m)
        {
            res=max(res,coins[i][j]+find(i+1,j,power,coins));
            if(coins[i][j]<0 && power>0)
                res=max(res,find(i+1,j,power-1,coins));
        }
        if(j+1<n)
        {
            res=max(res,coins[i][j]+find(i,j+1,power,coins));
            if(coins[i][j]<0 && power>0)
                res=max(res,find(i,j+1,power-1,coins));
        }

        return dp[i][j][power]=res;
    }
    int maximumAmount(vector<vector<int>>& coins) 
    {
        m=coins.size(),n=coins[0].size();
        dp.resize(m,vector<vector<int>>(n,vector<int>(3,INT_MIN)));
        return find(0,0,2,coins);
    }
};
```
['Dynamic Programming', 'C++']