Alternative Solution Binary Search | Explained
Intuition\nWell you can do this problem in many linear way but i tried to do this in binary search for a better understanding of binary Search algorithm.\nSo wh
# Intuition\nWell you can do this problem in many linear way but i tried to do this in binary search for a better understanding of binary Search algorithm.\nSo what are the left and right limits? Its the 0 and the max Jumbo burger we can create from given tomatoes(t).\nFind the remaining tomatoes left for making small burgers after making jumbo burgers, if it is equal to number of cheese(c) given return it as ans.\nNow suppose the total no of Jumbo + small burger < required Burger\n-> We are making more Jumbo than required shift right pointer\nelse:\nshift left pointer\n# Code\n```\nclass Solution:\n    def numOfBurgers(self, t: int, c: int) -> List[int]:\n        if t % 2 != 0: # its odd then 1 tomato will always be remaining\n          return []\n        totalJumbo = t // 4\n        left = 0\n        right = totalJumbo\n        while left < right:\n            mid = (left + right) // 2\n            remaining = t - (4 * mid)\n            totalSmall = remaining / 2\n            burgerPossible = mid + totalSmall\n            if burgerPossible == c:\n                return [mid, int(totalSmall)]\n            elif (burgerPossible) < c: # we are making more jumbo reduce it \n                right = mid\n            else:\n                left = mid + 1\n        remaining = t - (4 * left)\n        Small = remaining / 2\n        if left + Small == c:\n            return [left, int(Small)]\n        return []\n```
['Math', 'Binary Search', 'Sorting', 'Python3']