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.
- Prepare
- Data Structures
- Arrays
- Left Rotation
- Discussions
Left Rotation
Left Rotation
Sort by
recency
|
3518 Discussions
|
Please Login in order to post a comment
Here is my Java solution:
My solution was pretty simple, after trying looping over the array without success, I tried the most simplistic approach, dividing the array and then putting it all together, as the order doesn't change I just needed to extract the portion of items where d would be the "zero" index and append to it the rest of the array. One line needed, python 3, O(n) complexity
Next Java solution consider avoiding extra rotations.
Here is my c++ solution, you can have the video explanation here : https://youtu.be/lyUDSB4Sg7Y
Solution in Java