Students are queued by preference and sandwiches are served in fixed order. Return how many students are unable to eat lunch. Pattern focus: Queue Simulation. Rotate the queue until the current sandwich can be served, otherwise stop when no progress is possible.
students = preferences queue, sandwiches = sandwich stack order
number of students unable to eat
Example 1:
Input:
students = [1,1,0,0] sandwiches = [0,1,0,1]
Output:
0
Explanation:
All students can eventually take a sandwich they like.
Example 2:
Input:
students = [1,1,1,0,0,1] sandwiches = [1,0,0,0,1,1]
Output:
3
Explanation:
Three students remain without a sandwich they like.