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. Data Structures
  3. Arrays
  4. Left Rotation
  5. Discussions

Left Rotation

Problem
Submissions
Leaderboard
Discussions
Editorial

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

  • Pree92tham 4 years ago+ 0 comments

    Not the desired approach but it gets the job done though

    static void Main(String[] args) { string[] token=Console.ReadLine().Split(' '); int n=Convert.ToInt32(token[0]); int k=Convert.ToInt32(token[1]); string[] arr1=Console.ReadLine().Split(' '); int [] arr=Array.ConvertAll(arr1,int.Parse);

        int temp=0;
       Queue<int> l=new Queue<int>();
    
        for(int i=0;i<n;i++){
            l.Enqueue(arr[i]);
        }
    
        for(int j=0;j<k;j++){
            temp=l.Dequeue();
            l.Enqueue(temp);
    
    
        }
    
        foreach(int i in l){
            Console.Write("{0} ",i);
        }
    
    }
    
    3|
    ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature