Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- queue<int> modifyQueue(queue<int> q, int k)
- {
- stack<int> st;
- queue<int> q1;
- int coun=0;
- while(!q.empty())
- { if(coun==k) break;
- st.push(q.front());
- q.pop();
- coun++;
- }
- while(!st.empty())
- {
- q1.push(st.top());
- st.pop();
- }
- while(!q.empty())
- {
- q1.push(q.front());
- q.pop();
- }
- return q1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement