Lists say I have a list List {1,2,3,4,5}
List {1,2,3,4,5}
Rotate means:
=> {2,3,4,5,1} => {3,4,5,1,2} => {4,5,1,2,3}
You can use below code for left Rotation.
List backUpArray = array.ToList(); for (int i = 0; i < array.Length; i++) { int newLocation = (i + (array.Length - rotationNumber)) % n; array[newLocation] = backUpArray[i]; }