[C++][Bottom up DP solution]
Code
# Code
```cpp []
class Solution {
public:
    int maximumAmount(vector<vector<int>>& coins) {
        int m = coins.size(), n=coins[0].size(), ans=0;
        vector<vector<vector<int>>> dp(m+1, vector<vector<int>>(n+1,vector<int>(3, -500000)));
        dp[0][1][0]=0;

        for (int i=0;i<m;i++){
            for (int j=0;j<n;j++){
                dp[i+1][j+1][0] = max(dp[i][j+1][0],dp[i+1][j][0])+coins[i][j];
                dp[i+1][j+1][1] =  max(max(max(dp[i][j+1][1],dp[i+1][j][1]) +coins[i][j], max(dp[i][j+1][0],dp[i+1][j][0])),dp[i+1][j+1][0]);
                dp[i+1][j+1][2] = max(max(max(dp[i][j+1][2],dp[i+1][j][2]) +coins[i][j], max(dp[i][j+1][1],dp[i+1][j][1])),dp[i+1][j+1][1]);

                //cout << i << " " << j << " " << dp[i+1][j+1][0] << " " << dp[i+1][j+1][1] << " " << dp[i+1][j+1][2] << endl;
            }
        }
        return dp.back().back()[2];
    }
};
```
['C++']