Number of Students Unable to Eat Lunch Problem
Number of Students Unable to Eat Lunch Problem — ExecCode Easy DSA Practice
Solve the Number of Students Unable to Eat Lunch problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given two integer arrays students and sandwiches where sandwiches[i] is the type of the i^th sandwich in the stack (i = 0 is the top of the stack) and students[j] is the preference of the j^th student in the initial queue (j = 0 is the front of the queue). Your task is to compute the required answer and return the number of students that are unable to eat. 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.
Examples
Input {"students": [1, 1, 0, 0], "sandwiches": [0, 1, 0, 1]}; Output 0. 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.
Practice Number of Students Unable to Eat Lunch free on ExecCode. Browse DSA problems, topic map, and placement guides.