Skip to content

Practice Number of Burgers with No Waste of Ingredients

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1276
LeetCode Problem

Number of Burgers with No Waste of Ingredients

Problem Statement

A jumbo burger needs four tomato slices and one cheese slice; a small burger needs two tomato slices and one cheese slice. Return [total_jumbo,total_small] using nonnegative whole burger counts that consume exactly tomatoSlices and cheeseSlices. Return [] if no such combination exists.

Source: Number of Burgers with No Waste of Ingredients on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
tomatoSlices = 16, cheeseSlices = 7
Output
[1,6]
Explanation

To make one jumbo burger and 6 small burgers we need 4*1 + 2*6 = 16 tomato and 1 + 6 = 7 cheese. There will be no remaining ingredients.

# Example 2

Input
tomatoSlices = 17, cheeseSlices = 4
Output
[]
Explanation

There will be no way to use all ingredients to make small and jumbo burgers.

# Example 3

Input
tomatoSlices = 4, cheeseSlices = 17
Output
[]
Explanation

Making 1 jumbo burger there will be 16 cheese remaining and making 2 small burgers there will be 15 cheese remaining.

Constraints

0 <= tomatoSlices, cheeseSlices <= 10^7

Related LeetCode Problems

Practice more problems similar to Number of Burgers with No Waste of Ingredients.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.