✅ ⟣ | Memoization | 3D DP | Top Down Approach | CPP Solution  | Simple Approach | Clean Code
IntuitionBasic Recursion according to stepsApproachUsed Top Down ApproachCode
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

Basic Recursion according to steps 

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

Used Top Down Approach


# Code
```cpp []
class Solution {
public:
    int solve(vector<vector<int>>& coins, int row, int col, int neutralize,
              vector<vector<vector<int>>>& dp) {
        int n = coins.size();
        int m = coins[0].size();

        if (row >= n || col >= m) {
            return INT_MIN;
        }

        if (row == n - 1 && col == m - 1) {
            if (coins[row][col] < 0 && neutralize > 0) {
                return 0;
            }
            return coins[row][col];
        }

        if (dp[row][col][neutralize] != INT_MIN) {
            return dp[row][col][neutralize];
        }

        int moveRight = solve(coins, row, col + 1, neutralize, dp);
        int moveDown = solve(coins, row + 1, col, neutralize, dp);

        int profit = coins[row][col] + max(moveRight, moveDown);

        if (coins[row][col] < 0 && neutralize > 0) {
            profit =
                max(profit,
                    0 + max(solve(coins, row, col + 1, neutralize - 1, dp),
                            solve(coins, row + 1, col, neutralize - 1, dp)));
        }

        return dp[row][col][neutralize] = profit;
    }

    int maximumAmount(vector<vector<int>>& coins) {
        int n = coins.size();
        int m = coins[0].size();
        int neutralize = 2;

        vector<vector<vector<int>>> dp(
            n, vector<vector<int>>(m, vector<int>(neutralize + 1, INT_MIN)));

        return solve(coins, 0, 0, neutralize, dp);
    }
};

```
['C++']