C++ Backtracking Soln || Clean & Easy
class Solution {\npublic:\n    \n    void solve(int i,vector& top,int t,int sf,int& ans,int& diff){\n        // base case\n        if(i == top.size()){\n       
class Solution {\npublic:\n    \n    void solve(int i,vector<int>& top,int t,int sf,int& ans,int& diff){\n        // base case\n        if(i == top.size()){\n            \n            if(abs(t-sf) < diff){    // if the diff of cost if less than prev found diff\n                diff = abs(t-sf);          \n                ans = sf;\n            }\n            else if(abs(t-sf) == diff)   // if diff is same but value of cost is smaller\n                ans = min(ans,sf);\n                \n            return;\n        }\n        \n        solve(i+1, top,t, sf, ans, diff);           // No topping[i]\n        solve(i+1, top,t, sf+top[i], ans, diff);     // One topping[i]\n        solve(i+1, top,t, sf+(2*top[i]), ans, diff);    // Both topping[i]\n    }\n    \n    int closestCost(vector<int>& b, vector<int>& t, int tar) {\n        \n        int ans = INT_MAX;\n        int diff = INT_MAX;\n        \n        for(auto& x: b){     // Taking each base as a start cost\n            solve(0,t,tar,x,ans,diff);\n        }\n        \n        return ans;\n    }\n};
['Backtracking', 'C', 'C++']