We’re preparing your current view and syncing the latest data.
You are given two integer arrays students and sandwiches where sandwiches[i] is the type of the i-th sandwich in the stack (0 or 1), and students[j] is the preference of the j-th student in the queue (0 or 1). A sandwich can be taken only by a student who prefers its type, and students take sandwiches in order. If the student at the front of the queue cannot take the sandwich on top of the stack, they go to the end of the queue. The process repeats until no one can eat the top sandwich. Return the number of students unable to eat lunch.
Return an integer representing the number of students unable to eat lunch.
1 <= students.length == sandwiches.length <= 100 students[i] and sandwiches[i] are either 0 or 1.
Example 1
Input
students = [1,1,0,0] sandwiches = [0,1,0,1]
Output
0
Explanation
Students and sandwiches can be matched so all students can eat.
Example 2
Input
students = [1,1,1,0,0,1] sandwiches = [1,0,0,0,1,1]
Output
3
Explanation
After some students take their sandwiches, three students remain unable to eat.