Number of Burgers with No Waste of Ingredients LeetCode solution in Python
1class Solution(object):2def numOfBurgers(self, t, c):34if t == c == 0:5return [0, 0]6four = (t - 2 * c) // 2 # no of jumbo burgers by solving 4x+2y=t and x+y=c7two = c - four # number of small burgers8if (9c >= t or (t - 2 * c) % 2 == 1 or four < 0 or two < 010): # if cheese is less than tomatoes or if number of jumbo burgers is a decimal or number of burgers are negtive we return empty list11return []1213return [four, two]