Recursion || Memoization || Top Down approach || C++
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 tr(vector<vector<int>>&coins,int i,int j,int t,vector<vector<vector<int>>>&dp){
        if(i>=coins.size() || j>=coins[0].size()){
            // cout<<endl;
            return INT_MIN+1010;
        }
        if(i==coins.size()-1 && j==coins[0].size()-1){
            // cout<<endl;
            if(coins[i][j]<0 && t>=1){
                return 0;
            }
            return dp[i][j][t+1] = coins[i][j];
        
        }
        if(dp[i][j][t+1]!=INT_MIN){
            return dp[i][j][t+1];
        }

        int left = INT_MIN+1000;
        int right = INT_MIN+1000;
        // cout<<coins[i][j]<<" ";
        if(coins[i][j]>=0){
            left = coins[i][j] + tr(coins,i+1,j,t,dp);
            left = max(left,coins[i][j]+tr(coins,i,j+1,t,dp));
        }
        else{
            if(t<=0){
                right = coins[i][j] + tr(coins,i+1,j,t,dp);
                right = max(right,coins[i][j] +tr(coins,i,j+1,t,dp));
            }
            else{
                right = coins[i][j] + tr(coins,i+1,j,t,dp);
                right = max(right,coins[i][j] +tr(coins,i,j+1,t,dp));
                // cout<<t<<" ";
                // cout<<right<<" ";
                right = max(right,tr(coins,i+1,j,t-1,dp));
                right = max(right,tr(coins,i,j+1,t-1,dp));
                // cout<<right<<" ";
            }
        }
        return dp[i][j][t+1] = max(left,right);
    }
    int maximumAmount(vector<vector<int>>& coins) {
        vector<vector<vector<int>>>dp(coins.size()+1,vector<vector<int>>(coins[0].size()+1,vector<int>(4,INT_MIN)));
        return tr(coins,0,0,2,dp);
    }
};
```
['Array', 'Dynamic Programming', 'Recursion', 'Memoization', 'Matrix', 'C++']