• + 2 comments

    An easy Approch with vector insert and pop_back. 1 2 3 4 5 after 1st rotation 5 1 2 3 4 after second rotation 4 5 1 2 3 after 3rd rotation 3 4 5 1 2 and so on .........

        while(k--){
            int temp;
            temp=a[a.size()-1];
            a.insert(a.begin(),temp);
            a.pop_back();
        }
    vector<int>arr;
    for(int i=0; i<queries.size();i++)
           arr.push_back(a[queries[i]]);
    
    return arr;
    }