Traditional DP Approach || Easy to understand ✅✅
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. -->Try All Possible Ways using DP.

# 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 {
    Integer dp[][][];

    int maxCoins(int nums[][],int row,int col,int k){
        int n = nums.length; int m = nums[0].length;
        if(row>=n || row<0 || col>=m || col<0) return Integer.MIN_VALUE/2;
        if(row==n-1 && col==m-1){
            if(nums[row][col]>=0) return nums[row][col];
            if(nums[row][col]<0){
                if(k>0) return 0;
                return nums[row][col];
            }
        }
        if(dp[row][col][k]!=null) return dp[row][col][k];
        int right = Integer.MIN_VALUE/2, down = Integer.MIN_VALUE/2;

        if(nums[row][col]>=0){
            right = nums[row][col] + maxCoins(nums,row,col+1,k);
            down  = nums[row][col] + maxCoins(nums,row+1,col,k);
        }
        else{
            if(k>0){
                right = maxCoins(nums,row,col+1,k-1);
                down  = maxCoins(nums,row+1,col,k-1);
            }
            right = Math.max(right,nums[row][col] + maxCoins(nums,row,col+1,k));
            down  = Math.max(down,nums[row][col] + maxCoins(nums,row+1,col,k));

        }
        return dp[row][col][k] = Math.max(right,down);
    }

    public int maximumAmount(int[][] coins) {
        int n = coins.length; int m = coins[0].length;
        dp = new Integer[n][m][3];
        return maxCoins(coins,0,0,2);
    }
}
```
['Dynamic Programming', 'Depth-First Search', 'Memoization', 'C++', 'Java']