Simple Solution in Java || Elegant and Concise || Backtracking || 100% Faster
\nclass Solution {\n    private int closest;\n    private int ans;\n    \n    public int closestCost(int[] baseCosts, int[] toppingCosts, int target) {\n       
```\nclass Solution {\n    private int closest;\n    private int ans;\n    \n    public int closestCost(int[] baseCosts, int[] toppingCosts, int target) {\n        this.ans = 0;\n        this.closest = Integer.MAX_VALUE;\n        \n        // Check for each of the base \n        for(int baseCost : baseCosts){\n            find(0, baseCost, toppingCosts, target);\n        }\n        \n        return ans;\n    }\n    \n    private void find(int index, int costTillNow, int[] toppingCosts, int target){\n        if(Math.abs(target - costTillNow) < closest){\n            closest = Math.abs(target - costTillNow);\n            ans = costTillNow;\n        }\n        if(Math.abs(target - costTillNow) == closest){ // We want the lower number if two numbers are at the same distance \n            ans = Math.min(ans, costTillNow);\n        }\n        \n        if(costTillNow >= target || index >= toppingCosts.length) return;\n        \n        /*\n            We have three options:\n            1) Don\'t put the current topping\n            2) Take one toppings of current type\n            3) Take two toppings of current type \n        */\n        find(index+1, costTillNow, toppingCosts, target);\n        find(index+1, costTillNow + toppingCosts[index], toppingCosts, target);\n        find(index+1, costTillNow + 2*toppingCosts[index], toppingCosts, target);\n    }\n}\n```
[]