Elegant C++, Java, Go, Python, JavaScript: 2 lines, O(1) time&space
This clearly should be "Easy" not "Medium".\nCheck viability conditions first, then allocate greedily: jumbo = tomato/2 - cheese, small = cheese - jumbo.\n\nJav
This clearly should be "Easy" not "Medium".\nCheck viability conditions first, then allocate greedily: jumbo = tomato/2 - cheese, small = cheese - jumbo.\n\nJava\n``` \nclass Solution {\n    public List<Integer> numOfBurgers(int ts, int cs) {\n        if (ts%2==1 || ts/2<cs || ts/4>cs) return Collections.emptyList();\n        return Arrays.asList(ts/2-cs, 2*cs-ts/2);\n    }\n}\n```\nC++\n```\nclass Solution {\npublic:\n    vector<int> numOfBurgers(int ts, int cs) {\n        if (ts%2==1 || ts/2<cs || ts/4>cs) return {};\n        return {ts/2-cs, 2*cs-ts/2};\n    }\n};\n```\nGo\n```\nfunc numOfBurgers(ts int, cs int) []int {\n    if ts%2==1 || ts/2<cs || ts/4>cs {\n        return []int{}\n    } \n    return []int{ts/2-cs, 2*cs-ts/2}\n}\n```\nPython\n```\nclass Solution(object):\n    def numOfBurgers(self, ts, cs):\n        return [] if ts%2==1 or ts/2<cs or ts/4>cs else [ts/2-cs, 2*cs-ts/2]\n```\nJavaScript\n```\nfunction numOfBurgers(ts, cs) {\n    return ts%2==1 || ts/2<cs || ts/4>cs ? [] : [ts/2-cs, 2*cs-ts/2];\n}\n```
['C', 'Python', 'Java', 'Go', 'JavaScript']