Python Intuitive backtracking solution
I think this question is quite difficult but when I see the constraint, it becomes quite easy with backtracking.\n- Step 1: Generate all posible topping options
I think this question is quite difficult but when I see the constraint, it becomes quite easy with backtracking.\n- Step 1: Generate all posible topping options.\n```\nFor example: toppingCosts = [3,4], we have topping_options = [0, 4, 8, 3, 7, 11, 6, 10, 14]\n```\n- Step 2: Iterate from baseCosts and topping_options to find the closest one to target.\n\n```\nclass Solution:\n    def closestCost(self, baseCosts: List[int], toppingCosts: List[int], target: int) -> int:\n        # General all possible topping options and store it to topping_options\n        N, M = len(baseCosts), len(toppingCosts)\n        topping_options = []\n        \n        def bkt(index: int, total_toping_costs: int):\n            for v in [0, 1, 2]:\n                total_toping_costs += toppingCosts[index] * v\n\n                if index == M - 1:\n                    topping_options.append(total_toping_costs)\n                else:\n                    bkt(index + 1, total_toping_costs)\n\n                total_toping_costs -= toppingCosts[index] * v\n        \n        total_toping_costs = 0\n        bkt(0, total_toping_costs)\n        \n        # Find the closest option\n        ans = 0\n        distance = float(\'inf\')\n        \n        for baseCost in baseCosts:\n            for topping_option in topping_options:\n                if abs((baseCost + topping_option) - target) < distance:\n                    ans = baseCost + topping_option\n                    distance = abs((baseCost + topping_option) - target)\n                \n        return ans\n```                \n\t
[]