✅✅Easy C++ Solution || Simple to Understand
\tclass Solution {\n\tpublic:\n\t\tint countStudents(vector& students, vector& sandwiches) {\n\n\t\t\treverse(sandwiches.begin(), sandwiches.end());\n\n\t\t\tst
\tclass Solution {\n\tpublic:\n\t\tint countStudents(vector<int>& students, vector<int>& sandwiches) {\n\n\t\t\treverse(sandwiches.begin(), sandwiches.end());\n\n\t\t\tstack<int> st; // For sandwiches\n\t\t\tqueue<int> q;  // For Students\n\n\t\t\tfor(auto i : sandwiches){\n\t\t\t\tst.push(i);\n\t\t\t}\n\n\t\t\tfor(auto i : students){\n\t\t\t\tq.push(i);\n\t\t\t}\n\n\t\t\tint rotationCycle = 0;\n\t\t\twhile(!st.empty()){\n\n\t\t\t\tif(st.top() == q.front()){ \n\t\t\t\t\tq.pop();\n\t\t\t\t\tst.pop();\n\t\t\t\t\trotationCycle = 0;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tint temp = q.front();\n\t\t\t\t\tq.pop();\n\t\t\t\t\tq.push(temp);\n\n\t\t\t\t\trotationCycle++;\n\n\t\t\t\t\tif(rotationCycle >= q.size()){\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn st.size();\n\t\t}\n\t};\nI hope that you\'ve found the solution useful.\nIn that case, please do upvote. Happy Coding :)
['Stack', 'Queue', 'C', 'C++']