Java Clean Dp Solution
Code\n\nclass Solution {\n    private int solveMemo(List<List<Integer>> piles, int idx, int k, int[][] dp) {\n        // Base case\n        if (idx >= piles.siz
# Code\n```\nclass Solution {\n    private int solveMemo(List<List<Integer>> piles, int idx, int k, int[][] dp) {\n        // Base case\n        if (idx >= piles.size() || k <= 0) {\n            return 0;\n        }\n\n        // step-2 =>if dp[idx][k] is calculated just return it..\n        if (dp[idx][k] != -1) {\n            return dp[idx][k];\n        }\n\n        // step-3 =>if dp[idx][k] isn\'t calculated just calculate it...\n        int res = solveMemo(piles, idx + 1, k, dp);\n        int count = 0;\n        for (int i = 0; i < piles.get(idx).size() && i < k; i++) {\n            count += piles.get(idx).get(i);\n            res = Math.max(res, count + solveMemo(piles, idx + 1, k - i - 1, dp));\n        }\n        return dp[idx][k] = res;\n    }\n\n\n\n    public int maxValueOfCoins(List<List<Integer>> piles, int k) {\n        // step-1 => dp creation....\n        int[][] dp = new int[piles.size() + 1][k + 1];\n        for (int[] d : dp) {\n            Arrays.fill(d, -1);\n        }\n\n        return solveMemo(piles, 0, k, dp);\n    }\n}\n```
['Array', 'Dynamic Programming', 'Recursion', 'Memoization', 'Prefix Sum', 'Java']