THis is what I want to do: array A[] = {1,2,3,4,5} left rotate by 2: A:{3,4,5,1,2}
do we have a simple and good solution for doing this in place? I want the array A itself to be updated with this left rotated value - with no additional space.
I tried various approaches but the logic seems different for various test cases and had a hard time finding one algorithm that fits for this seemingly simple task.
NOTE: I know this can be easily done by just creating a new array with the left rotated values. I am trying to do this in the input array itself.
Pls suggest. Simple pseudo code should do.
See Question&Answers more detail:os