[Java/C++/Python] Array, Time O(N) Space O(1)
Explanation\nFirstly, we count all 0\'s and 1s. In the second loop, we check sandwiches for existed people from top to bottom and count all people who can eat t
**Explanation**\nFirstly, we count all 0\'s and 1s. In the second loop, we check sandwiches for existed people from top to bottom and count all people who can eat the desired sandwich. Then, subtract the number of people who can able to eat from the total one.\n\n**Complexity**\n\nTime ```O(N)```\nSpace ```O(2)```\n\n**Java:**\n```\npublic int countStudents(int[] students, int[] sandwiches) {\n\xA0 \xA0 \xA0 \xA0 int[] a = {0, 0};\n\xA0 \xA0 \xA0 \xA0 for (int i=0;i<students.length;i++)\n\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 a[students[i]]+=1;\n\xA0 \xA0 \xA0 \xA0 int k = 0;\n\xA0 \xA0 \xA0 \xA0 while (k < sandwiches.length){\n\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 if (a[sandwiches[k]] > 0)\n\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 a[sandwiches[k]]-=1;\n\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 else\n\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 break;\n\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 k+=1;}\n\xA0 \xA0 \xA0 \xA0 return sandwiches.length-k;\n\xA0 \xA0 }\n```\n**C++**\n```\n\tint countStudents(vector<int>& students, vector<int>& sandwiches) {\n\t\xA0 \xA0 \xA0 \xA0 int a[] = {0, 0};\n\t\xA0 \xA0 \xA0 \xA0 for (int i=0;i<students.size();i++)\n\t\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 a[students[i]]+=1;\n\t\xA0 \xA0 \xA0 \xA0 int k = 0;\n\t\xA0 \xA0 \xA0 \xA0 while (k < sandwiches.size()){\n\t\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 if (a[sandwiches[k]] > 0)\n\t\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 a[sandwiches[k]]-=1;\n\t\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 else\n\t\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 break;\n\t\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 k+=1;}\n\t\xA0 \xA0 \xA0 \xA0 return sandwiches.size()-k;\n\xA0 \xA0 \n\xA0 \xA0 }\n```\n**Python**\n```\n\xA0  def countStudents(self, students: List[int], sandwiches: List[int]) -> int:\n\xA0 \xA0 \xA0 \xA0 a =[0,0]\n\xA0 \xA0 \xA0 \xA0 for st in students:\n\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 a[st]+=1\n\xA0 \xA0 \xA0 \xA0 k = 0\n\xA0 \xA0 \xA0 \xA0 while k < len(sandwiches):\n\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 if a[sandwiches[k]]>0:\n\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 a[sandwiches[k]]-=1\n\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 else:\n\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 break\n\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 k+=1\n\xA0 \xA0 \xA0 \xA0 return len(sandwiches)-k\n```
['C', 'Python', 'Java']