Backtracking || C++
```\n void recur(int currcost,vector& tC,int target,int topindex,int &cost)\n    {\n        if(topindex==tC.size())\n        {\n        if(abs(target-currcost) 
```\n void recur(int currcost,vector<int>& tC,int target,int topindex,int &cost)\n    {\n        if(topindex==tC.size())\n        {\n        if(abs(target-currcost) < abs(target-cost) || (abs(target-currcost)==abs(target-cost)) && currcost<cost)\n        {\n            cost=currcost;\n        }\n            return;\n        }\n        for(int i=0;i<=2;i++)\n        {\n            recur(currcost+(tC[topindex]*i),tC,target,topindex+1,cost);\n        }\n    }\n    int closestCost(vector<int>& baseCosts, vector<int>& toppingCosts, int target) {\n        int ans=INT_MAX;\n        for(int i=0;i<baseCosts.size();i++)\n        {\n            recur(baseCosts[i],toppingCosts,target,0,ans);\n        }\n        return ans;\n    }
[]