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.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Data Structures
  3. Arrays
  4. Left Rotation
  5. Discussions

Left Rotation

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 3208 Discussions, By:

recency

Please Login in order to post a comment

  • yashbaddi
    1 day ago+ 0 comments

    My Javascript Code:

    function rotateLeft(d, arr) {
        // Write your code here
        let res=[...arr]
        for(let i=0;i<d;i++){
            res.push(res.shift())
        }
        return res
    }
    
    0|
    Permalink
  • kirimiwayne
    2 days ago+ 0 comments
    public static List<Integer> rotateLeft(int d, List<Integer> arr) {
        // Write your code here
            int len = arr.size();
            List<Integer> newArr = new ArrayList<>();
            int i = d;
            int j = 0;
            
            while(i < len){            
                newArr.add(arr.get(i));
                i++;
            }  
            
            while(j < d){            
                newArr.add(arr.get(j));
                j++;
            }                      
            return newArr;
        }
    
    0|
    Permalink
  • xXxAboodxXx
    3 days ago+ 0 comments

    Javascript

    function rotateLeft(d, arr) {
        for(let i=0;i<d;i++){
            arr.push(arr.shift())
        }
        return arr
    }
    
    0|
    Permalink
  • shahsamir1297
    4 days ago+ 0 comments

    c++ int i=0; while(i<d){ int temp=arr[0]; arr.erase(arr.begin()); arr.push_back(temp); i++;}

    0|
    Permalink
  • arunkumar_pcse21
    4 days ago+ 0 comments

    public static List rotateLeft(int d, List arr) { int i=0; while(i

    return arr;
    }**``````````**
    
    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy