JAVA || 100% Faster || Easy With Comment || Two Approach
\n//Approach 1\n\nclass Solution\n{//brute-force approach i.e accprdinvg to the problen statement \n public int countStudents(int[] students, int[] sandwiches) 
```\n//Approach 1\n\nclass Solution\n{//brute-force approach i.e accprdinvg to the problen statement \n public int countStudents(int[] students, int[] sandwiches) \n {//T-> O(n^2) S->O(n)\n\tQueue<Integer> line=new LinkedList<Integer>();\n\tStack<Integer> menu=new Stack<Integer>();\n\n\tfor(int i: students)//pushing the students into the queue according to the probleem statement\n        {\n\t     line.offer(i);\n\t}\n\n\tfor(int i=sandwiches.length-1;i>=0;i--)//pushing in reverse order it order to acess the top at first \n        {\n\t    menu.push(sandwiches[i]);\n\t}\n\n\tint counter=line.size()*menu.size();//maximum possible iteration possible \n\twhile(counter-->0)\n        {\n\t\tif((!menu.isEmpty())&&line.peek()==menu.peek())//if the student has got the sandwitch he wants \n                {\n\t\t    line.poll();\n\t\t    menu.pop();\n\t\t}\n\t\telse//if the student has not got the sandwitch he wants \n                {\n                   if(line.size()>0)//waiting for the desired sandwich in the line \n                   {\n\t\t      line.offer(line.remove());//removing from the front of the queue and adding at the rear of the queue \n                   }\n                   else\n                      return 0;//if line size is zero means every student has got the sandwitch, no one is left to consume sandwitch so returning zero \n\t\t}\n        }\n\treturn line.size();\n }//Please do vote me, It helps a lot\n}\n```\n```\n//Approach 2\n\nclass Solution\n{\n    public int countStudents(int[] students, int[] sandwiches) \n    {//T -> O(n) S ->O(1)\n        int[] a ={0, 0};//acts as a database to keep track of number of sandwich consumed vs expected \n        \n        for(int i=0;i<students.length;i++)\n        {\n            a[students[i]]+=1;//counting number of 0s and 1s (which sandwich is required)\n        }\n        \n        int k = 0;///traversing the index of the the sandwitchs //acctuallly eating the sandwich \n        \n        while(k < sandwiches.length)\n        {\n            if(a[sandwiches[k]] > 0)\n            {//students eated the desired sandwich from top to bottom \n                a[sandwiches[k]]-=1;//consumed sandwich \n            }\n            else\n            {//demand and supply not met \n                break;//we have but they want some other sandwitch \n            }\n            k+=1;//moving the index \n        }\n        return sandwiches.length-k;//number of people has not eaten the sandwitch \n    }\n}//Please do vote me, It helps a lot\n```
['Stack', 'Queue', 'Java']