Answers for "Rotate Left k cells java"

0

Rotate Left k cells java

public static int [] rotateLeft(int [] source, int k) {
    int arr[] = new int[source.length];

    for (int i = 0; i < arr.length; i++){
        arr[(i - k + source.length) % source.length] = source[i];
    }

    return arr; 
}
Posted by: Guest on July-03-2021

Browse Popular Code Answers by Language