Number of Burgers with No Waste of Ingredients LeetCode solution in Python

1
class Solution(object):
2
def numOfBurgers(self, t, c):
3

4
if t == c == 0:
5
return [0, 0]
6
four = (t - 2 * c) // 2 # no of jumbo burgers by solving 4x+2y=t and x+y=c
7
two = c - four # number of small burgers
8
if (
9
c >= t or (t - 2 * c) % 2 == 1 or four < 0 or two < 0
10
): # if cheese is less than tomatoes or if number of jumbo burgers is a decimal or number of burgers are negtive we return empty list
11
return []
12

13
return [four, two]

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0