Number of Burgers with No Waste of Ingredients - Problem
Given two integers tomatoSlices and cheeseSlices, determine how many burgers can be made with no waste of ingredients.
The ingredients required for different burgers are:
- Jumbo Burger: 4 tomato slices and 1 cheese slice
- Small Burger: 2 tomato slices and 1 cheese slice
Return [total_jumbo, total_small] such that the number of remaining tomatoSlices equals 0 and the number of remaining cheeseSlices equals 0. If it is not possible to achieve zero waste, return [].
Input & Output
Example 1 — Basic Case
$
Input:
tomatoSlices = 16, cheeseSlices = 7
›
Output:
[1,6]
💡 Note:
1 jumbo burger (4 tomatoes + 1 cheese) + 6 small burgers (12 tomatoes + 6 cheese) = 16 tomatoes + 7 cheese total
Example 2 — Only Small Burgers
$
Input:
tomatoSlices = 10, cheeseSlices = 5
›
Output:
[0,5]
💡 Note:
0 jumbo burgers + 5 small burgers (10 tomatoes + 5 cheese) uses all ingredients perfectly
Example 3 — Impossible Case
$
Input:
tomatoSlices = 4, cheeseSlices = 17
›
Output:
[]
💡 Note:
Not enough tomatoes to satisfy minimum requirement (2 tomatoes per cheese slice). 4 < 2×17 = 34
Constraints
- 0 ≤ tomatoSlices ≤ 107
- 0 ≤ cheeseSlices ≤ 107
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code