[C++] Easy to understand solution
\nclass Solution {\npublic:\n    int ans = 999999;\n    unordered_map<int, int> mp;\n    int closestCost(vector<int>& b, vector<int>& t, int target) {\n        
```\nclass Solution {\npublic:\n    int ans = 999999;\n    unordered_map<int, int> mp;\n    int closestCost(vector<int>& b, vector<int>& t, int target) {\n        //Works without sort\n        sort(begin(b), end(b));\n        sort(begin(t), end(t));\n        \n        //for each base choose toppings combinations\n        for(int i = 0; i<b.size(); i++){\n            mp = {};\n            solve( t, 0, target, b[i]);\n        }\n        \n        return ans;\n    }\n    \n    void solve(vector<int> &t, int j, int target, int sum){\n       if(abs(ans-target) > abs(ans-target))\n           return;\n        \n        mp[j]++;\n        \n        if(j >= t.size() || mp[j] <= 2){\n            if(abs(sum-target) < abs(ans-target)){\n                ans = sum;\n           \n            }else if(abs(sum-target) == abs(ans-target) && ans > sum){\n                ans = sum;\n     \n            }\n            if(j >= t.size())\n                return;\n        }\n        solve(t, j+1, target, sum + t[j]);\n        solve(t, j+1, target, sum);\n        solve(t, j+1, target, sum + t[j] + t[j]);\n         \n    }\n};\n```
[]