Clean C++ Code
\n\n// - There must be exactly one ice cream base.\n// - You can add one or more types of topping or have no toppings at all.\n// - There are at most two of eac
```\n\n// - There must be exactly one ice cream base.\n// - You can add one or more types of topping or have no toppings at all.\n// - There are at most two of each type of topping.\n\nclass Solution {\nprivate: \n    int res = INT_MAX; \npublic:\n    int closestCost(vector<int>& baseCosts, vector<int>& toppingCosts, int target) {\n        int n = toppingCosts.size();\n        \n        for (int i = 0; i < baseCosts.size(); i++) {\n            vector<int> toppings(n, 0); \n\t\t\t\n            // add baseCost as a start and try different topping combinations\n            helper(baseCosts[i], toppings, toppingCosts, target);\n        }\n        \n        return res;\n    }\n    \n    void helper(int cost, vector<int>& toppings, vector<int>& toppingCosts, int target) {\n\t   // handle the termination condition first. Don\'t forget the case when target is 9, we should return 8 instead of 10 since its smaller.\n        if (abs(cost - target) < abs(res - target) || \n            (abs(cost - target) == abs(res - target) && cost < res)) res = cost; \n        \n        if (cost > target) return; \n        \n        for (int i = 0; i < toppings.size(); i++) {\n            if (toppings[i] == 2) continue; \n            \n            toppings[i]++; \n            \n            helper(cost + toppingCosts[i], toppings, toppingCosts, target); \n            \n            toppings[i]--; // backtracking and try next one\n        }\n    }\n};\n\n```
['C']