PHP Dynamic Programming
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: $$O(k * s)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(k)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution\n{\n\n    /**\n     * @param Integer[][] $piles\n     * @param Integer $k\n     * @return Integer\n     */\n    function maxValueOfCoins($piles, $k)\n    {\n        $a = array_fill(0, 2, array_fill(1, $k, 0));\n        $c = 0;\n        foreach ($piles as $pile) {\n            for ($i = 1; $i <= $k; $i++) {\n                for ($j = 0, $s = 0, $kk = min($i, count($pile)) ; $j < $kk; $j++) {\n                    $s += $pile[$j];\n                    $a[$c][$i] = max($a[$c][$i], $a[1 - $c][$i], $s + $a[1 - $c][$i - $j - 1]);\n                }\n            }\n            $c = 1 - $c;\n        }\n\n        return end($a[1 - $c]);\n    }\n}\n\n```
['Dynamic Programming', 'PHP']