DP recursion with Memoization 
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
```java []
class Solution {
    int f(int[][] coins , int i , int j , int k , Integer[][][] dp){
        int n = coins.length;
        int m = coins[0].length;
        
        if(i == n-1 && j == m-1){
            if(coins[i][j] > 0 ){
                return coins[i][j];
            }
            else{
                if(k > 0) return 0;
                else return coins[i][j];
            }

        }
        
        if(i == coins.length || j == coins[0].length) return Integer.MIN_VALUE;
        if(dp[i][j][k]!=null) return dp[i][j][k];
        if(coins[i][j] > 0 ){
            return dp[i][j][k] =coins[i][j] + Math.max(f(coins , i +1 , j , k , dp) , f(coins , i , j+1 , k , dp)); 
        }
        else{
            if(k > 0){
                int skip = Math.max(f(coins , i +1 , j , k-1 , dp) , f(coins , i , j+1 , k-1 , dp));
                int give = coins[i][j] +  Math.max(f(coins , i +1 , j , k ,dp) , f(coins , i , j+1 , k, dp));
                return dp[i][j][k]=  Math.max(skip , give);
            }
            else{
                return dp[i][j][k]=  coins[i][j] +  Math.max(f(coins , i +1 , j , k , dp) , f(coins , i , j+1 , k , dp));
            }
        }
    }
    public int maximumAmount(int[][] coins) {
          int n = coins.length;
        int m = coins[0].length;
       return f(coins , 0 , 0 , 2 , new Integer[n+1][m+1][3]);
    }
}
```
['Java']