shlogg · Early preview
Md Ariful Haque @mah-shamim

Counting Unhappy Students: Sandwich Preferences And Queue Dynamics

Students unable to eat lunch due to sandwich mismatch. Algorithm counts students who can't take sandwiches based on their preference and stack order. Solution uses array count values and foreach loop to determine number of students left hungry.

1700. Number of Students Unable to Eat Lunch
Easy
The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circular sandwiches.
The number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed in a stack. At each step:

If the student at the front of the queue prefers the sandwich on the top of the stack, they will take it and leave the queue.
Otherwise, they will leave it and go to the queue's end.

This continues until none...