class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param students int整型vector
* @param sandwiches int整型vector
* @return int整型
*/
int countStudents(vector<int>& students, vector<int>& sandwiches) {
int n = sandwiches.size() ;
int j = 0 ;
queue<int>s ;
for(int i : students)
{
s.push(i) ;
}
while(s.size())
{
if(s.front() == sandwiches[j])
{
s.pop() ;
j++ ;
}
else
{
int h = s.size() ;
while(s.front() != sandwiches[j])
{
h-- ;
s.push(s.front()) ;
s.pop() ;
if(h == 0)
{
return s.size() ;
}
}
}
}
return 0 ;
}
};