JAVA || 3D DP
Code

# Code
```java []
class Solution {
    static int n;
    static int m;
    public int maximumAmount(int[][] coins) {
        n = coins.length;
        m = coins[0].length;

        int dp[][][] = new int[n][m][3];
        
        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++) {
                Arrays.fill(dp[i][j], Integer.MIN_VALUE);
            }
        }
        
        return findMaxAns(coins, 0, 0, 2, dp);    
    }


    
    int findMaxAns(int coins[][], int i, int j, int limit, int dp[][][]) {
        if(i == n-1 && j == m-1) {
            if(limit > 0) return Math.max(0, coins[n-1][m-1]);
            return coins[n-1][m-1];
        }

        if(dp[i][j][limit] !=  Integer.MIN_VALUE) {
            return dp[i][j][limit];
        }

        int left = Integer.MIN_VALUE;
        int right = Integer.MIN_VALUE;

        if(i+1 < n) {
            
           if(coins[i][j] < 0 && limit > 0) {
               left = findMaxAns(coins, i+1, j, limit-1, dp);
           } 
         
            left = Math.max(findMaxAns(coins, i+1, j, limit, dp)+coins[i][j], left);
           
        }

        if(j+1 < m) {

            if(coins[i][j] < 0 && limit > 0) {
                right = findMaxAns(coins, i, j+1, limit-1, dp); 
                right = Math.max(findMaxAns(coins, i, j+1, limit, dp)+coins[i][j], right);
            } 

            right = Math.max(findMaxAns(coins, i, j+1, limit, dp)+coins[i][j], right);
        }


        return dp[i][j][limit] = Math.max(right, left);
    }
}


// [0,1,-1]
// [1,-2,3]
// [2,-3,4]
```
['Java']