• + 0 comments

    First, Intialize starting position k= k%2. then,from this first postion (k) use a for loop till (n-1) to assign the values in the new array and finally use another for loop from 0 to (k-1).

    the O(n) of this algorithm is n and it works for all test cases.

            k=k%n;
            j=0;
            for(i=0+k;i<n;i++)
            {
                newarr[i]=arr[j];
                j++;
            }
            for(i=0;i<k;i++)
            {
                newarr[i]=arr[j];
                j++;
            }