C# Solution for Number of Students Unable to Eat Lunch Problem
Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition behind this approach is to iterate through the students and sandwiches si
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition behind this approach is to iterate through the students and sandwiches simultaneously, keeping track of the count of remaining sandwiches of each type. We then decrement the count of sandwiches as students take them until either all sandwiches are eaten or no more students can eat.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1.\tInitialize an array count to keep track of the count of remaining sandwiches of each type.\n2.\tIterate through the students array and update the counts of sandwiches for each type.\n3.\tIterate through the sandwiches array, decrementing the count of sandwiches of the current type if available.\n4.\tStop iterating when either all sandwiches are eaten or no more students can eat.\n5.\tReturn the number of students who couldn\u2019t eat.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n), where n is the length of the sandwiches array. The solution iterates through the sandwiches array once and performs constant time operations within each iteration.\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1), as the solution uses a fixed-size array count of size 2 to keep track of the count of remaining sandwiches of each type. The space used does not depend on the size of the input arrays.\n\n# Code\n```\npublic class Solution {\n    public int CountStudents(int[] students, int[] sandwiches) {\n        int[] count = new int[2]; // count[0] for circular sandwiches, count[1] for square sandwiches\n        \n        foreach (int student in students) {\n            count[student]++;\n        }\n        \n        int i = 0;\n        while (i < sandwiches.Length) {\n            if (count[sandwiches[i]] == 0) {\n                break; // No more students who prefer this type of sandwich\n            }\n            \n            count[sandwiches[i]]--; // Mark one sandwich as eaten by a student\n            \n            i++;\n        }\n        \n        return students.Length - i;\n    }\n}\n```
['C#']