Practice Number of Students Unable to Eat Lunch
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
students lists a queue of preferences, with index 0 at its front. sandwiches lists a stack with index 0 on top; 0 means circular and 1 means square. If the front student wants the top sandwich, remove both; otherwise move that student to the queue's end. Stop when no remaining student wants the top sandwich. Return the number of students left without food.
Source: Number of Students Unable to Eat Lunch on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
students = [1,1,0,0], sandwiches = [0,1,0,1]
0
# Example 2
students = [1,1,1,0,0,1], sandwiches = [1,0,0,0,1,1]
3
Constraints
Related LeetCode Problems
Practice more problems similar to Number of Students Unable to Eat Lunch.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.