Easy C++ Dp --> Memoization Without Prefix Sum
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\nMEMOIZATION\n```\nclass Solution {\npublic:\n    int solve(int i,int k,vector<vector<int>>& dp,vector<vector<int>>& piles)\n    {\n        if(k==0)return 0;\n        if(i>=piles.size())return 0;\n        if(dp[i][k]!=-1)return dp[i][k];\n        int np = solve(i+1,k,dp,piles);\n        int p=0;\n        int sum=0;\n        for(int ind=0;ind<piles[i].size() and ind+1<=k;ind++)\n        {\n            sum+=piles[i][ind];\n            p=max(p,sum+solve(i+1,k-ind-1,dp,piles));\n            \n        }\n        return dp[i][k]=max(p,np);\n    }\n int maxValueOfCoins(vector<vector<int>>& piles, int k) {\n        \n        int n=piles.size();\n        vector<vector<int>> dp(n+1,vector<int> (k+1,-1));\n        return solve(0,k,dp,piles);  \n }\n```
['C++']