Only one test case running fine

IT SHOWS CORRECT OUTPUT WITH THE GIVEN INPUT TEST CASE. AM I MISSIN SOME IMPORTANT CORNER CASE?

Hi @vijit.chandhok99, pls see that your code is not working for testcases where k is >= n.
For example:

// Input
7
1 2 2 1 8 5 6
7
// Expected Output
1 2 2 1 8 5 6
// Your Output
2 2 1 8 5 6 1       which is same as that when k will be given as 6.

In this question k can be greater than n.

Now pls see that what part will get printed when k will be greater than.

Hope this helps :slight_smile:

i just handled the case of k==n but i am not able to figure out what difference will it make when it is k>n

Hi @vijit.chandhok99, lets see what happens if k = 9.
we simply put as many no. of elements in the front of list which are possible
which in this case is 7 because list has maximum 7 elements.

Let me name this shifting of all n elements to obtain the list to be same as original as task 1.

now after we have shifted seven elements, i.e. done with task 1; we are left with 9 - 7 = 2 elements to be shifted. i.e. we now need to shift 2 more elements.

so the list becomes:

6 7 1 2 3 4 5

also lets take an example where k = 17.

now lets do task1 here i.e. shift maximum possible elements i.e. all 7 elements to front
we are now left with 17 - 7 = 10
again we shift maximum no. of elements, i.e. we perform task 1 and now we are left with 10-7 = 3
elements.
now we shift he last 3 elements to front so the final output will be:

5 6 7 1 2 3 4

this is what happens if k is larger than n.

Hope this helps :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.