Juggling Algorithm

Algorithm:

  • Divide the array in different sets where number of sets is equal to GCD of len and number of rotation and move the elements within sets.

  • This algorithm works for left rotation of array.

Example of len =12 and rotate = 3. GCD is 3

Geeks for geeks

Last updated

Was this helpful?