C++ Simple Maths | Explanation | 0ms
Solving Equations:\nLet no of big burgers be X,\nLet no of small burgers be Y,\nthen,\n4X + 2Y=T             (i)\nX + Y=C         (ii)\nfrom (ii),          Y=C-
Solving Equations:\nLet no of big burgers be X,\nLet no of small burgers be Y,\nthen,\n4X + 2Y=T             (i)\nX + Y=C         (ii)\nfrom (ii),          Y=C-X\n4X + 2 (C-X) =T\n4X + 2C - 2X=T\n2X + 2C=T\nX=(T - 2C) / 2        : where T= tomatoslices and C= cheeseslices which is given.\n& Y= C-X\nhence {X,Y} is the answer.\t\t   \n```\nclass Solution {\npublic:\n    vector<int> numOfBurgers(int tomatoSlices, int cheeseSlices) {\n        if(tomatoSlices%2!=0)\n            return {};\n        if(cheeseSlices<tomatoSlices/4)\n            return {};\n        if(cheeseSlices>tomatoSlices/2)\n            return {};\n        int x=(tomatoSlices-(2*cheeseSlices))/2;\n        int y=cheeseSlices-x;\n        return {x,y};\n    }\n};\n```\nPlease Upvote if you like!!!
[]