Easy C++ Solution
IntuitionApproachComplexity
Time complexity:O(M*N)

Space complexity:O(M*N)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:O(M*N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:O(M*N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
int solve(int i,int j,vector<vector<int>>&coins,int cnt,vector<vector<vector<int>>>&dp){
    int m=coins.size();
    int n=coins[0].size();
    if(i<0 || i>=m || j<0 || j>=n){
        return -1e8;
    }
    if(i==m-1 && j==n-1){
    if(coins[i][j]>=0) return coins[i][j];
    else{
        if(cnt>0) return 0;
        return coins[i][j];
    }
    }
    if(dp[i][j][cnt]!=INT_MIN){
        return dp[i][j][cnt];
    }
    if(coins[i][j]>=0){
        int right=coins[i][j]+solve(i,j+1,coins,cnt,dp);
        int down=coins[i][j]+solve(i+1,j,coins,cnt,dp);
        return dp[i][j][cnt]=max(right,down);
    }else{
        if(cnt>0){
             int right=solve(i,j+1,coins,cnt-1,dp);
        int down=solve(i+1,j,coins,cnt-1,dp);
          int rightwithneg=coins[i][j]+solve(i,j+1,coins,cnt,dp);
        int downwithneg=coins[i][j]+solve(i+1,j,coins,cnt,dp);
        
     return dp[i][j][cnt] =max(max(right, down), max(rightwithneg, downwithneg));

        }else{
             int right=coins[i][j]+solve(i,j+1,coins,cnt,dp);
        int down=coins[i][j]+solve(i+1,j,coins,cnt,dp);
        return dp[i][j][cnt]= max(right,down);
        }
    }
}
    int maximumAmount(vector<vector<int>>& coins) {
        int m=coins.size();
    int n=coins[0].size();
    vector<vector<vector<int>>>dp(m+1,vector<vector<int>>(n+1,vector<int>(3,INT_MIN)));
    return solve(0,0,coins,2,dp);

    }
};
```
['C++']