✅Simple 10th Math Formula | Easy Explanation
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nif the value of tomato is less then cheese then we can not find no of jum
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nif the value of tomato is **less then** cheese then we can not find no of jumbo and small so return {}\n\n ```\n\n You just need to slove thise two equations\n        Jumbo        |        Small           \n        Tomato = 4   |        Tomato = 2 \n        Cheese = 1   |        Cheese = 1\n                     |\n\n        4*jumbo + 2*small = tomato;  ---- 1\n        1*jumbo + 1*small = cheese;  ---- 2  \n\n\n        Multiplaby by 2 in equation 2\n        4*jumbo + 2*small = tomato;  \n        2*jumbo + 2*small = 2*cheese;  \n         -         -         -\n        ------------------------------------\n    Now we can cancle 2*small from both of eqation then we will get\n    \n    2*jumbo = tomato - 2*cheese\n    jumbo = (tomato - 2*cheese) / 2;\n\n    then put the value of jumbo for finding the value of small in equation 1\n    \n    samll = cheese - jumbo \n\n```\n\n# Direct formulas \n**jumbo = (tomato - 2*cheese) / 2**\n\n**samll = cheese - jumbo** \n\n\n# Complexity\n- Time complexity: O(1)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n\n```C++ []\nclass Solution {\npublic:\n    vector<int> numOfBurgers(int tomato, int cheese) {\n        if (tomato < cheese) {\n            return {};\n        }\n        4 * jumbo + 2 * small = tomato;\n        1 * jumbo + 1 * small = cheese;\n        int jumbo = (tomato - (2 * cheese)) / 2;\n        int small = cheese - jumbo;\n        tomato -= 4 * jumbo + 2 * small;\n        cheese -= jumbo + small;\n        if (tomato == 0 && cheese == 0 && jumbo >= 0 && small >= 0) {\n            return {jumbo, small};\n        }\n        return {};\n    }\n};\n```\n```python []\nclass Solution:\n    def numOfBurgers(self, tomato, cheese):\n        # Check if the input is valid\n        if tomato < cheese:\n            return []\n        \n        # 4 * jumbo + 2 * small = tomato\n        # 1 * jumbo + 1 * small = cheese\n        jumbo = (tomato - (2 * cheese)) // 2\n        small = cheese - jumbo\n        \n        tomato -= 4 * jumbo + 2 * small\n        cheese -= jumbo + small\n        \n        if tomato == 0 and cheese == 0 and jumbo >= 0 and small >= 0:\n            return [jumbo, small]\n        \n        return []\n\n```\n```Java []\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class Solution {\n    public List<Integer> numOfBurgers(int tomato, int cheese) {\n        List<Integer> result = new ArrayList<>();\n        \n        if (tomato < cheese) {\n            return result;\n        }\n        int jumbo = (tomato - (2 * cheese)) / 2;\n        int small = cheese - jumbo;\n        \n        tomato -= 4 * jumbo + 2 * small;\n        cheese -= jumbo + small;\n        \n        if (tomato == 0 && cheese == 0 && jumbo >= 0 && small >= 0) {\n            result.add(jumbo);\n            result.add(small);\n        }\n        \n        return result;\n    }\n}\n\n```\n
['Python', 'C++', 'Java']