[C++] || Pure - Recursion
\nclass Solution {\npublic:\n    int ans = 1e5 + 1;\n    \n    void solve(int pos,vector<int>&TC , int currCost , int &T ){\n        if(abs(currCost - T) < abs(
```\nclass Solution {\npublic:\n    int ans = 1e5 + 1;\n    \n    void solve(int pos,vector<int>&TC , int currCost , int &T ){\n        if(abs(currCost - T) < abs(ans-T)) ans = currCost ;\n        if(abs(currCost-T) == abs(ans-T)) ans = min(ans,currCost) ;\n        \n        if(pos >= TC.size() ) return ;\n        //pick zero topping \n        solve(pos+1,TC,currCost + TC[pos]*0 ,T) ;\n        //pick one topping\n        solve(pos+1,TC,currCost + TC[pos],T) ;\n        //pick two toppings \n        solve(pos+1,TC,currCost+TC[pos]*2,T) ;\n        \n    }\n    int closestCost(vector<int>& BC, vector<int>& TC, int T) {\n        for(auto &currCost : BC) solve(0,TC,currCost,T) ;\n        return ans ;\n    }\n};\n```
[]