Skip to content

Commit b0131f5

Browse files
authored
Create 1700. Number of Students Unable to Eat Lunch (#451)
2 parents 70b0050 + 0e1bab3 commit b0131f5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public:
3+
int countStudents(vector<int>& students, vector<int>& sandwiches) {
4+
vector<int> count(2, 0);
5+
for (int student : students)
6+
count[student]++;
7+
8+
for (int i = 0; i < sandwiches.size(); ++i) {
9+
if (count[sandwiches[i]] == 0)
10+
return sandwiches.size() - i;
11+
count[sandwiches[i]]--;
12+
}
13+
14+
return 0;
15+
}
16+
};

0 commit comments

Comments
 (0)