Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 663 Bytes

1.md

File metadata and controls

32 lines (25 loc) · 663 Bytes
 queue<int> modifyQueue(queue<int> q, int k) {
     
        vector<int>a;
        int n=q.size();
        
        for(int i=0;i<k;i++)
        {
            a.push_back(q.front());
            q.pop();
        }
        
        reverse(a.begin(),a.end());
        int i=0;
        
        while(i!=a.size())
        {
            q.push(a[i]);
            i++;
        }
        
        for(int i=0;i<n-k;i++)
        {
            q.push(q.front());
            q.pop();
        }
        
        return q;
    }