#include <queue> class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param students int整型vector * @param sandwiches int整型vector * @return int整型 */ int countStudents(vector<int>& students, vector<int>& sandwiches) { queue<int> Stud; queue<int> Sand; for (int i=0; i<students.size(); ++i) { Stud.push(students[i]); Sand.push(sandwiches[i]); } int len = 0; int temp; while (!Stud.empty()) { if (Stud.front()==Sand.front()) { Stud.pop(); Sand.pop(); len = 0; }else if(Stud.front()!=Sand.front() && len!=Stud.size()){ temp = Stud.front(); Stud.pop(); Stud.push(temp); len++; //多的人数等于所有的学生了 }else { break; } } return Stud.size(); } };