diff --git a/1700. Number of Students Unable to Eat Lunch b/1700. Number of Students Unable to Eat Lunch new file mode 100644 index 0000000..f9c624f --- /dev/null +++ b/1700. Number of Students Unable to Eat Lunch @@ -0,0 +1,16 @@ +class Solution { +public: + int countStudents(vector& students, vector& sandwiches) { + vector count(2, 0); + for (int student : students) + count[student]++; + + for (int i = 0; i < sandwiches.size(); ++i) { + if (count[sandwiches[i]] == 0) + return sandwiches.size() - i; + count[sandwiches[i]]--; + } + + return 0; + } +};