Untitled
Anonymous
plain_text
08/21/2023 4:44 PM
604 B
18
Indexable
#include <bits/stdc++.h>
void interLeaveQueue(queue < int > & q) {
queue<int>q2;
int n=q.size();
for(int i=0;i<n/2;i++){ //taking 1st half of q into q2
int f=q.front();
q.pop();
q2.push(f);
}
while(!q2.empty()){ //intermittently adding q and q2
int f1=q2.front();
q2.pop();
q.push(f1);
int f2=q.front();
q.pop();
q.push(f2);
}
}Editor is loading...