Please tell me what i am doing wrong

Hello @sarthaksingh,

You have missed an important part of the question:
K can be greater than N.

Example:
7
1 2 2 1 8 5 6
8
Expected Output:
6 1 2 2 1 8 5
Your Output:
1 2 2 1 8 5 6

Observation:
The required output is the same as that of k=1.
Similarly,
for k=7 the output is the same as that of k=0.
for k=9 the output is the same as that of k=2.

Solution:
k = k mod n;
this would limit the value of k within the range [0,n-1]

Modified Code:

Hope, this would help.
Give a like, if you are satisfied.