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.

Arrays left rotation - In this video, I have explained Arrays left rotation hackerrank solution algorithm.
hackerrank Arrays left rotation problem can be solved by using auxilary array.

If interested to know more about the generic algorithm in details-

Thanks bro, it mathematical approach I like it.
but i thing you done misticks in this code?
for (int oldIndex = 0; oldIndex < n; oldIndex++) {
int newIndex = (oldIndex + d) % n;
rotArray[newIndex] = a[oldIndex];
}

Hello, thank you for sharing your approach with us. I have a question :
Is using auxiliary array allowed? In the problem description we can read the following : "A left rotation operation on an array of size n shifts each of the array's elements unit to the left...". Please note the word shifts. Because of that, I assume that we must operate on only 1 array. Is my assumption wrong?

## Left Rotation

You are viewing a single comment's thread. Return to all comments →

Hello friends,

Arrays left rotation - In this video, I have explained Arrays left rotation hackerrank solution algorithm. hackerrank Arrays left rotation problem can be solved by using auxilary array.

If interested to know more about the generic algorithm in details-

click here for the

video explanation of generic algorithmwith complexity analysis.or you can click on the image too to follow youtube tutorial.

Here is the working solution:-source code :Would really appreciate your feedback like, dislike , comment etc. on my video.

## Do not forget to upvote, if you find it useful.

Thanks bud.

most welcome. It would be great if you can provide your feedback like, dislike , comment etc. on my video. It motivate me to do more for you all

Thanks bro, it mathematical approach I like it. but i thing you done misticks in this code? for (int oldIndex = 0; oldIndex < n; oldIndex++) { int newIndex =

(oldIndex + d) % n;rotArray[newIndex] = a[oldIndex]; }thanks buddy for pointing the typo in code. I have corrected the same.

It should be

new index=(old index+n-d)%n;

thanks buddy for pointing the typo in code. I have corrected the same.

Hello, thank you for sharing your approach with us. I have a question : Is using auxiliary array allowed? In the problem description we can read the following : "A left rotation operation on an array of size n shifts each of the array's elements unit to the left...". Please note the word

shifts. Because of that, I assume that we must operate on only 1 array. Is my assumption wrong?