Python short and clean. Recursive. DP. Functional programming.
Complexity\n- Time complexity: O(m * k)\n\n- Space complexity: O(m)\n\nwhere,\nm is number of total coins from all piles\n\n# Code\npython\nclass Solution:\n   
# Complexity\n- Time complexity: $$O(m * k)$$\n\n- Space complexity: $$O(m)$$\n\nwhere,\n`m is number of total coins from all piles`\n\n# Code\n```python\nclass Solution:\n    def maxValueOfCoins(self, piles: list[list[int]], k_: int) -> int:\n        prefix_piles = [list(accumulate(p, initial=0)) for p in piles]\n\n        @cache\n        def max_value(n: int, k: int) -> int:\n            return max(\n                max_value(n - 1, k - i) + x\n                for i, x in enumerate(islice(prefix_piles[n - 1], k + 1))\n            ) if n and k else 0\n        \n        return max_value(len(piles), k_)\n\n\n```
['Array', 'Dynamic Programming', 'Prefix Sum', 'Python', 'Python3']