~0ms🔰beats100% | its sad😔 DON'T COPY OTHER's CODE PL's😔🔰Counting and Matching method🔰
Counting: Initially, we count the number of students who prefer each type of sandwich (0s and 1s).\nMatching: Then, we iterate through the sandwiches. For each 
> Counting: Initially, we count the number of students who prefer each type of sandwich (0s and 1s).\nMatching: Then, we iterate through the sandwiches. For each sandwich, we check if there are any /* ---------\uD83D\uDE14 DON\'T COPY OTHER CODE PL\'\uD83D\uDE14---------------*/Sstudents left who prefer that type of sandwich. If so, we decrement the count for that type of sandwich.\nThis approach efficiently counts the number of unsatisfied students by matching sandwiches with students\' preferences.\n![im sleepy \uD83D\uDCA4\uD83C\uDF19\u2601\uFE0F.jpg](https://assets.leetcode.com/users/images/55e874a1-4847-4bfe-991f-cf6fb1578cf4_1712539619.3854144.jpeg)\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nimport \njava.\nutil.\nStack\n;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 class Solution {public int countStudents(int[] students, int[] sandwiches) {int count[] = new int[2];for (int student : students) {count[student]++;}for (int sandwich : sandwiches) {if (count[sandwich] == 0) {break;}count[sandwich]--;}return count[0] + count[1];}}\n```
['Java']