From 0e1bab391a00d0c844a3564193e445b2e7161ebd Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Tue, 9 Apr 2024 01:42:22 +0530 Subject: [PATCH] Create 1700. Number of Students Unable to Eat Lunch --- 1700. Number of Students Unable to Eat Lunch | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 1700. Number of Students Unable to Eat Lunch 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; + } +};