C++ || MEMOIZATION || DP || EASY TO UNDERSTNAD
\nclass Solution {\npublic:\n    int solve(vector<vector<int>> &v,vector<vector<int>> &dp,int s,int k,int &n){\n        if(s>=n)return 0;\n        if(k==0)retur
````\nclass Solution {\npublic:\n    int solve(vector<vector<int>> &v,vector<vector<int>> &dp,int s,int k,int &n){\n        if(s>=n)return 0;\n        if(k==0)return 0;\n        if(dp[s][k] != -1)return dp[s][k];\n        int mx = solve(v,dp,s+1,k,n);\n        int cur = 0;\n        for(int i = 0; i < v[s].size(); i++){\n            cur += v[s][i];\n            if(k-i-1 >= 0){\n                mx = max(mx,cur+solve(v,dp,s+1,k-i-1,n));\n            }\n        }\n        return dp[s][k] = mx;\n    }\n    int maxValueOfCoins(vector<vector<int>>& piles, int k) {\n        int n = piles.size();\n        vector<vector<int>> dp(n+1,vector<int> (k+1,-1));\n        return solve(piles,dp,0,k,n);\n    }\n};\n````
['Dynamic Programming', 'Recursion', 'Memoization', 'C', 'C++']