Online C++ Compiler - Programiz
Fri Sep 20 2024 08:12:27 GMT+0000 (Coordinated Universal Time)
Saved by
@deshmukhvishal2
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void findStudentsUnableToEatLunch(queue<int> food, queue<int>students){
int foodNotMatched =0;
while(!food.empty()){
if(students.front() == food.front()){
food.pop();
students.pop();
}else{
foodNotMatched++;
if(foodNotMatched == students.size()){
break;
}else{
students.push(students.front());
students.pop();
}
}
}
cout<<"The element remaning is: " << students.size()<<endl;
}
int main() {
//Write your C++ code here
queue<int> food;
food.push(1);
food.push(0);
food.push(0);
food.push(0);
food.push(1);
food.push(1);
queue<int> students;
students.push(1);
students.push(1);
students.push(1);
students.push(0);
students.push(0);
students.push(1);
findStudentsUnableToEatLunch(food,students);
return 0;
}
content_copyCOPY
https://www.programiz.com/cpp-programming/online-compiler/
Comments