JAVA || Easy Solution || DP ||
\n\n# Code\nPLEASE UPVOTE IF YOU LIKE.\n\nclass Solution {\n    public int maxValueOfCoins(List<List<Integer>> piles, int k) {\n        int numPiles = piles.siz
\n\n# Code\nPLEASE UPVOTE IF YOU LIKE.\n```\nclass Solution {\n    public int maxValueOfCoins(List<List<Integer>> piles, int k) {\n        int numPiles = piles.size();\n        \n        int[][] dp = new int[numPiles+1][k+1];\n        \n        for(int i=1; i<=numPiles; i++){\n            for(int j=1; j<=k; j++){\n                dp[i][j] = dp[i-1][j]; \n                List<Integer> currPile = piles.get(i-1);\n                int coinSum = 0;\n                for(int l=0; l < Math.min(currPile.size(), j); l++){\n                    coinSum += currPile.get(l);\n                    dp[i][j] = Math.max(dp[i][j], coinSum + dp[i-1][j - l - 1]); \n                }\n            }\n        }\n        \n        return dp[numPiles][k];\n    }\n}\n```
['Java']