Left Rotation

This solution is simple that it takes the rotation in a loop. Inside the loop the first element of the array is extracted and the rest of the array shifted. The extracted array is then pushed at the end of the array. This cycle continues until it completes via the supplied number of cycles.

Computed Results Expected Output Rotation
3,4,5,1,2 3,4,5,1,2 2
45,66,34,12,43,76,76 45,66,34,12,43,76,76 25
25 25 11
21
683,256,987,234,25,16,87,45,654,342 683,256,987,234,25,16,87,45,654,342 258

© 2022 - Over Engineered by Carlo I Macasaet for crimsontechnik.com

Facebook Instagram Twitter GitHub Dribbble