Maximum Value of K Coins From Piles C#
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\n```\npublic class Solution {\n    public int MaxValueOfCoins(IList<IList<int>> piles, int k) {\n               int n = piles.Count;\n        int[][] dp = new int[n + 1][];\n        for (int i = 0; i < dp.Length; i++) {\n            dp[i] = new int[k + 1];\n        }\n        for (int i = 1; i <= n; i++) {\n            for (int coins = 0; coins <= k; coins++) {\n                int current_sum = 0;\n                for (int current_coins = 0; current_coins <= Math.Min(piles[i - 1].Count, coins); current_coins++) {\n                    if (current_coins > 0) {\n                        current_sum += piles[i - 1][current_coins - 1];\n                    }\n                    dp[i][coins] = Math.Max(dp[i][coins], dp[i - 1][coins - current_coins] + current_sum);\n                }\n            }\n        }\n        return dp[n][k]; \n    }\n}\n```
['C#']