Number of Burgers with No Waste of Ingredients LeetCode solution in JavaScript
1/**2* @param {number} tomatoSlices3* @param {number} cheeseSlices4* @return {number[]}5*/6var numOfBurgers = function (tomatoSlices, cheeseSlices) {7if (tomatoSlices & 1) return []; // return [] if tomatoSlices is odd8const j = (tomatoSlices >> 1) - cheeseSlices; // jumbo = (tomatoSlices / 2) - cheeseSlices9return j < 0 || j > cheeseSlices ? [] : [j, cheeseSlices - j]; // small = cheeseSlices - jumbo, if any of jmbo and small < 0 return [] otherwise return [jumbo, small]10};