C++ | Easy To Understand | Upvote If Helpful
class Solution {\npublic:\n    int countStudents(vector& students, vector& sandwiches) {\n        \n        queue st;\n        queue sa;\n        for(int i=0; i
class Solution {\npublic:\n    int countStudents(vector<int>& students, vector<int>& sandwiches) {\n        \n        queue<int> st;\n        queue<int> sa;\n        for(int i=0; i<students.size(); i++){\n            st.push(students[i]);\n            sa.push(sandwiches[i]);\n        }\n        int front=0;\n        int flag=st.size();\n        while(!st.empty() && !sa.empty()){\n            if(st.front()==sa.front()){\n                st.pop();\n                sa.pop();\n                flag=st.size();\n            }\n            else if(flag==0)\n                break;\n            else{\n                st.push(st.front());\n                st.pop();\n            }\n            flag--;\n        }\n        return st.size();\n    }\n};
[]