Skip to content

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.

Easy#1700
LeetCode Problem

Number of Students Unable to Eat Lunch

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

Input
students = [1,1,0,0], sandwiches = [0,1,0,1]
Output
0

# Example 2

Input
students = [1,1,1,0,0,1], sandwiches = [1,0,0,0,1,1]
Output
3

Constraints

1 <= students.length, sandwiches.length <= 100
students.length == sandwiches.length
sandwiches[i] is 0 or 1.
students[i] is 0 or 1.

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.