Reccursive dp/ memoization/ Clean code
IntuitionApproachComplexity
Time complexity: O(m * n * 3)

Space complexity: O(m * n * 3)
UPVOTE if you found it helpfull :)
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->Keep calculating the maximum coins collected by going through the grid ans skip negative coins when allowed

# Approach
<!-- Describe your approach to solving the problem. -->use a 3D dynamic programming table to store the results for each cell and the remaining skips.

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

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

# ___UPVOTE if you found it helpfull___ :)
```java []
class Solution {
    public int solve(int[][] coins, int i, int j, int k, Integer dp[][][]) {
        if (i >= coins.length || j >= coins[0].length) return Integer.MIN_VALUE;
        
        if (i == coins.length-1 && j == coins[0].length-1) {
            if (coins[i][j] < 0 && k > 0)  return 0;
            return coins[i][j];
        }
        if (dp[i][j][k] != null) return dp[i][j][k];
        
        int skip = Integer.MIN_VALUE;
        
        int take = coins[i][j] + Math.max(solve(coins, i + 1, j, k, dp), solve(coins, i, j + 1, k, dp));
        if (coins[i][j] < 0 && k > 0) {
            skip = Math.max(solve(coins, i + 1, j, k - 1, dp), solve(coins, i, j + 1, k - 1, dp));
        }
        
        return dp[i][j][k] = Math.max(take, skip);
    }
    public int maximumAmount(int[][] coins) {
        int n = coins.length, m = coins[0].length;
        Integer dp[][][] = new Integer[n][m][3];
        return solve(coins, 0, 0, 2, dp);
    }
}
```
['Array', 'Math', 'Dynamic Programming', 'Depth-First Search', 'Memoization', 'Matrix', 'Java']