Arrays: Left Rotation

  • + 0 comments

    This answer is true for right shifting, for left shifting test cases are failing.

    for(int i = 0; i < lengthOfArray; i++){ int newLocation = (i + (lengthOfArray - shiftAmount)) % lengthOfArray; a[newLocation] = in.nextInt(); }

    This is correct answer for left shifting.