C++(4ms) ||99.96%faster||Backtracking(Very Simple)||Explained
Check for each base.\n2. Change the closest number according to the difference. If difference is same check if its is smaller than previous. If different update
1. Check for each base.\n2. Change the closest number according to the difference. If difference is same check if its is smaller than previous. If different update the difference and closest number.\n3. We have 3 option either to take 1 of a topping type, 2  of a topping type or 0.\n```\nclass Solution {\npublic:\n    int ans=INT_MAX;\n    int num=INT_MAX;\n    void getAns(vector<int>&a,int target,int cur,int i){\n        if(cur>target&&abs(cur-target)>ans)return;\n        if(i>=a.size()){\n            if(abs(cur-target)==ans){\n                num=min(num,cur);\n            }\n            else if(abs(cur-target)<ans){\n                ans=abs(cur-target);\n                num=cur;\n            }\n            return;\n        }\n        \n        getAns(a,target,cur,i+1);\n        getAns(a,target,cur+a[i],i+1);\n        getAns(a,target,cur+2*a[i],i+1);\n        \n    }\n    int closestCost(vector<int>& baseCosts, vector<int>& toppingCosts, int target) {\n        num=ans=INT_MAX;\n        \n        for(int i=0;i<baseCosts.size();i++){\n            getAns(toppingCosts,target,baseCosts[i],0);\n        }\n        return num;\n    }\n};\n```
[]