Free written solutionNumber of Students Unable to Eat Lunch (LeetCode 1700): Solution and Explanation
Students in a queue take the top sandwich only if it is their preferred shape, otherwise they move to the back. Return how many students never eat. For students = [1,1,1,0,0,1] and sandwiches = [1,0,0,0,1,1] the answer is 3.
Read the intuition, approach, code and complexity →