Python DP Memoization
\nclass Solution:\n    def closestCost(self, baseCosts: List[int], toppingCosts: List[int], target: int) -> int:\n        self.toppingCosts = toppingCosts\n    
```\nclass Solution:\n    def closestCost(self, baseCosts: List[int], toppingCosts: List[int], target: int) -> int:\n        self.toppingCosts = toppingCosts\n        self.toppingCount = len(toppingCosts)\n        \n        return min([base + self.helper(0, target - base) \n                    for base in baseCosts], key=lambda x: (abs(x - target), x))  \n    \n    @lru_cache(maxsize = None)\n    def helper(self, idx, target):\n        # I have no more toppings to take\n        # or taking any more toppings is just going me to bring me further and further\n        if idx >= self.toppingCount or target <= 0:\n            return 0\n        \n        res = min([\n            # I don\'t take any of this, and move to the next one\n            self.helper(idx + 1, target),\n            \n            # I take one of this, and move to the next one\n            self.toppingCosts[idx] +  self.helper(idx + 1, target - self.toppingCosts[idx]),\n            \n            # I take two of this, and move to the next one\n            2 * self.toppingCosts[idx] +  self.helper(idx + 1, target - 2 * self.toppingCosts[idx])\n        ], key = lambda x: (abs(x - target), x))\n\t\t\n        return res\n```\nRuntime; 73 ms\nMemory: 16.1 MB
[]