1 2 3 4 5 6 7 8 9 10 11 12 13
| class Solution { public List<Integer> numOfBurgers(int tomatoSlices, int cheeseSlices) { int twiceSmall = 4 * cheeseSlices - tomatoSlices; if (twiceSmall < 0 || twiceSmall % 2 != 0 || twiceSmall > 2 * cheeseSlices) { return Collections.emptyList(); }
int small = twiceSmall / 2; int jumbo = cheeseSlices - small;
return Arrays.asList(jumbo, small); } }
|
References
1276. Number of Burgers with No Waste of Ingredients