C++   RECURSION + TOP-DOWN
// recursion \n\nint solve(vector<vector<int>>& arr,int i,int k,int n){\n    if (k==0 || i==n)\n    {\n        return 0;\n    }\n    int ans=0;\n    for (int j 
// recursion \n```\nint solve(vector<vector<int>>& arr,int i,int k,int n){\n    if (k==0 || i==n)\n    {\n        return 0;\n    }\n    int ans=0;\n    for (int j = 0; j <=k; j++)\n    {\n        if (arr[i].size()>=j)\n        {\n            if(j==0){\n                ans=max(ans,solve(arr,i+1,k,n)) ;\n            }\n            else{\n            ans=max(ans,arr[i][j-1]+solve(arr,i+1,k-j,n));\n            }\n        }\n        else{\n            return ans;\n        }\n    }\n    return ans;\n}\n int maxValueOfCoins(vector<vector<int>>& arr, int k) {\n        int n=arr.size();\n        for (int i = 0; i < n; i++)\n        {\n            for (int j = 1; j < arr[i].size(); j++)\n            {\n               arr[i][j]+=arr[i][j-1];\n            }\n            \n        }\n        return solve(arr,0,k,n);\n    }\n\t\n\t\n\t\n\t\n```\n\t// Top-Down\n\n```\nint solve(vector<vector<int>>& arr,int k2,int n){\n    vector<vector<int>>dp(n+1,vector<int>(k2+1,0));\n    for (int i = n-1; i >=0; i--)\n    {\n        for (int k = 0; k<=k2; k++)\n        {\n          \n                for (int j = 0; j <=k; j++)\n                {\n                    if (arr[i].size()>=j)\n                    {\n                        if(j==0){\n                            dp[i][k]=max(dp[i][k],dp[i+1][k]) ;\n                        }\n                        else{\n                        dp[i][k]=max(dp[i][k],arr[i][j-1]+dp[i+1][k-j]);\n                        }\n                    }\n                    else{\n                        break;\n                    }\n    }\n   \n\n\n        }\n        \n    }\n    return dp[0][k2];\n    \n\n\n\n }\n\n  int maxValueOfCoins(vector<vector<int>>& arr, int k) {\n        int n=arr.size();\n        for (int i = 0; i < n; i++)\n        {\n            for (int j = 1; j < arr[i].size(); j++)\n            {\n               arr[i][j]+=arr[i][j-1];\n            }\n            \n        }\n        return solve(arr,k,n);\n    }\n```
['Recursion', 'C++']