Untitled
unknown
plain_text
2 years ago
453 B
8
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...