Easy Recursive solution with DP Memoization || Beginner Friendly || 3-D DP Solution ||
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

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

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

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

# Code
```cpp []
class Solution {
public:
    int f(int row,int col,int cur,vector<vector<int>>&coins,vector<vector<vector<int>>>&dp){
        if(row==coins.size()-1 && col==coins[0].size()-1){
            if(coins[row][col]>=0){  
                return coins[row][col];
            }
            else if(cur>0){
                return 0;
            }
            else{
                return coins[row][col];
            }
        }
        if(row>=coins.size() || col>=coins[0].size()){
            return -250000000;
        }
        if(dp[row][col][cur]!=-1){
            return dp[row][col][cur];
        }
        int one=0;
        int two=0;
        if(cur>0){
            if(coins[row][col]>=0){
                one=coins[row][col]+f(row+1,col,cur,coins,dp);
                two=coins[row][col]+f(row,col+1,cur,coins,dp);
            }
            else{
                one=max(coins[row][col]+f(row+1,col,cur,coins,dp),f(row+1,col,cur-1,coins,dp));
                two=max(coins[row][col]+f(row,col+1,cur,coins,dp),f(row,col+1,cur-1,coins,dp));
                // three=0+f(row+1,col,cur-1,coins);
                // four=0+f(row,col+1,cur-1,coins);
            }
        }
        else{
            if(coins[row][col]>=0){
                one=coins[row][col]+f(row+1,col,cur,coins,dp);
                two=coins[row][col]+f(row,col+1,cur,coins,dp);
            }
            else{
                one=coins[row][col]+f(row+1,col,cur,coins,dp);
                two=coins[row][col]+f(row,col+1,cur,coins,dp);
            }
        }
        return dp[row][col][cur]=max(one,two);
    }
    int maximumAmount(vector<vector<int>>& coins) {
        vector<vector<vector<int>>>dp(coins.size(),vector<vector<int>>(coins[0].size(),vector<int>(3,-1)));
        return f(0,0,2,coins,dp);
    }
};
```
['Dynamic Programming', 'Recursion', 'Memoization', 'C++']