[C++] bottom up DP
```\nclass Solution {\npublic:\n    int maxValueOfCoins(vector>& piles, int k) {\n        int n=piles.size();\n\t\t//dp[i][j] - > maximum total value of coins u
```\nclass Solution {\npublic:\n    int maxValueOfCoins(vector<vector<int>>& piles, int k) {\n        int n=piles.size();\n\t\t//dp[i][j] - > maximum total value of coins using i piles and j coins.\n        vector<vector<int>> dp(n+1,vector<int>(k+1));\n\t\t// store the prefix sum for each pile.\n        for(int i=0;i<n;i++)\n            for(int j=1;j<(int)piles[i].size();j++)\n                piles[i][j]+=piles[i][j-1];\n            \n\t\t\n        for(int i=1;i<=n;i++)\n            for(int j=1;j<=k;j++) // calculate max total value to pick  j coins using i piles.\n                for(int w=0;w<=(int)piles[i-1].size() and w<=j;w++) // check for all combinations of coins that sum upto j coins. we can pick w coins from this pile and j-w coins from previous piles(dp[i-1][j-w]) i.e=> (j-w)+w=j coins in total.\n                    dp[i][j]=max(dp[i][j],dp[i-1][j-w]+((w-1>=0)?piles[i-1][w-1]:0));\n        \n        return dp[n][k];\n    }\n};
['Dynamic Programming', 'Iterator']