Beginner friendly easy to understand
IntuitionSimple solution with just normal pick and nopick method.ApproachUsing memoizationComplexity

Time complexity:
O(n×m)


Space complexity:
O(n×m)

Code
# Intuition
Simple solution with just normal pick and nopick method.

# Approach
Using memoization

# Complexity
- Time complexity:
O(n×m)

- Space complexity:
O(n×m)

# Code
```cpp []
class Solution {
public:
    int helper(vector<vector<int>>& coins,int k,int i,int j,vector<vector<vector<int>>> &dp){
        if(i>=coins.size() || j>=coins[0].size()){
            return -10000000;
        }
        if(i==coins.size()-1 && j==coins[0].size()-1){
            if(k>0 && coins[i][j]<0){
                return 0;
            }
            return coins[i][j];
        }
        if(dp[i][j][k]!=INT_MIN){
            return dp[i][j][k];
        }
        int b=INT_MIN;
        int a=coins[i][j]+max(helper(coins,k,i+1,j,dp),helper(coins,k,i,j+1,dp));
        if(k>0 && coins[i][j]<0){
            int down=helper(coins,k-1,i+1,j,dp);
            int right=helper(coins,k-1,i,j+1,dp);
            b=max(down,right);
        }
        return dp[i][j][k]=max(a,b);
    }
    int maximumAmount(vector<vector<int>>& coins) {
        vector<vector<vector<int>>> dp(coins.size(),vector<vector<int>> (coins[0].size(), vector<int> (3,INT_MIN)));
        return helper(coins,2,0,0,dp);
    }
};
```
['Array', 'Depth-First Search', 'Memoization', 'Matrix', 'C++']