Simple | Queue Only | C++ | Beginner friendly | with comments
Consider upvoting if u understood \uD83E\uDD42. Thanks\n\nclass Solution {\npublic:\n    int countStudents(vector<int>& students, vector<int>& sandwiches) {\n  
Consider upvoting if u understood \uD83E\uDD42. Thanks\n```\nclass Solution {\npublic:\n    int countStudents(vector<int>& students, vector<int>& sandwiches) {\n       queue<int> q;\n       int n = students.size();\n       // initialize top of sandwiches arr \n       int sIdx = 0;\n       // make a queue of students\n       for(int x : students)\n       {\n           q.push(x);\n       }\n       // count of students not able to eat sandwich at sIdx index \n       int notAble = 0;\n       // if q becomes empty then everyone ate and if no one can eat than notAble count will be equal to size of queue\n       while(q.size() && notAble < q.size())\n       {\n           // get curr student of queue\n           int curr = q.front();\n           q.pop();\n           // if ate\n           if(curr == sandwiches[sIdx])\n           {\n               // set notAble = 0 for circular check\n               notAble = 0;\n               // increase the sandwich index to the next sandwich \n               sIdx++;\n           }\n           else\n           {\n               // increase not eaten student count \n               notAble++;\n               // and push again at the back of queue \n               q.push(curr);\n           }\n       }\n        // return remaining students in the queue \n       return q.size();\n    }\n};\n```
[]