You are viewing a single comment's thread. Return to all comments →
With my solution I used modular arithmetic to calculate the position of the each element and placed them as I read from input.
for(int i = 0; i < lengthOfArray; i++){ int newLocation = (i + (lengthOfArray - shiftAmount)) % lengthOfArray; a[newLocation] = in.nextInt(); }
Arrays: Left Rotation
You are viewing a single comment's thread. Return to all comments →
With my solution I used modular arithmetic to calculate the position of the each element and placed them as I read from input.