We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  2. Algorithms
  3. Implementation
  4. Circular Array Rotation
  5. Discussions

Circular Array Rotation

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • hackernitp 4 years ago+ 0 comments
    #include <map>
    #include <set>
    #include <list>
    #include <cmath>
    #include <ctime>
    #include <deque>
    #include <queue>
    #include <stack>
    #include <string>
    #include <bitset>
    #include <cstdio>
    #include <limits>
    #include <vector>
    #include <climits>
    #include <cstring>
    #include <cstdlib>
    #include <fstream>
    #include <numeric>
    #include <sstream>
    #include <iostream>
    #include <algorithm>
    #include <unordered_map>
    
    using namespace std;
    
    
    int main(){
        int n;
        int k;
        int q;
        cin >> n >> k >> q;
        vector<int> a(n);
        for(int a_i = 0;a_i < n;a_i++){
           cin >> a[a_i];
        }
        
        for(int i=0;i<k;i++){
            for(int j=0;j<n;j++){
                if(j+1!=n)
                {
                    a[j+1]=a[j];
                    
                }
                   else
                   {
                       a[0]=a[n-1];
                   }
            }
        }
        for(int a0 = 0; a0 < q; a0++){
            int m;
            cin >> m;
        cout<<a[m]<<endl;}
        return 0;
    }
    

    can you plz tell me what is wrong with my code???

    -27|
    ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature