C++ | Memoization
```\nvector> dp;\n    int func(vector>& p,int i,int k){\n        if(i==p.size()) return 0;\n        if(dp[i][k]!=-1) return dp[i][k];\n        int ans=func(p,i+
```\nvector<vector<int>> dp;\n    int func(vector<vector<int>>& p,int i,int k){\n        if(i==p.size()) return 0;\n        if(dp[i][k]!=-1) return dp[i][k];\n        int ans=func(p,i+1,k);\n        int a=0;\n        for(int j=0;j<p[i].size()&&j<k;j++){\n            a+=p[i][j];\n            ans=max(ans,a+func(p,i+1,k-j-1));\n        }\n        return dp[i][k]=ans;\n    }\n    int maxValueOfCoins(vector<vector<int>>& p, int k) {\n        dp=vector<vector<int>>(p.size(),vector<int>(k+1,-1));\n        return func(p,0,k);\n    }
['Dynamic Programming', 'Memoization', 'C']