Search
⌘K

Leetcode 1276. Number of Burgers with No Waste of Ingredients

Given counts of tomato and cheese slices, find nonnegative integers (jumbo, small) so that 4*tomatoes_per_jumbo+2*tomatoes_per_small equals tomatoSlices and jumbo+small equals cheeseSlices, or return [] if impossible. This reduces to a simple linear Diophantine check: tomatoSlices must be even and 2*cheeseSlices <= tomatoSlices <= 4*cheeseSlices, yielding jumbo = tomatoSlices/2 - cheeseSlices and small = cheeseSlices - jumbo.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.