Hi All,
Thanks for your time/effort.
I want to rotate an int array by kth position my method signature will look like this
public void RotateArray(int[] A, int pos)
{
int len = A.Length - 1;
int temp = A[len];
int i = 0;
while (i < len)
{
Console.WriteLine("the value of i" +i);
A[i + 1] = A[i];
Console.WriteLine("the value of Array element : " + A[i]);
i++;
}
}
I tried to rotate it by 1 position i.e if i give an array of {1,2,3,4} expected result would be {4,1,2,3} . But my method here is not working as expected Please help me.
I want to write a method which will work for any number.
Regards
Sangeetha