Arrays: Left Rotation

  • + 0 comments

    Well done! I did it by finding the correct number for the index, rather than the new position of a given number:

    for (int i =0; i < n; i++){
        int num = a[((n + k) % n + i) % n];
        System.out.print((num) + " ");
    }