2 test cases are giving wrong output
It is mentioned in the question that K can be greater than N. You have not handled those cases. Try the sample input with K>7 for your code, it is giving the same linked list as result.
what will be the output if k > 7, I think it should give the same output. if, i am wrong can you tell me sample output for k > 7
Sure. The linked list in sample input is : 1 2 2 1 8 5 6
For K=7, you will get same linked list as output. But for K=8, you should get output as 6 1 2 2 1 8 5 which is the same as that for K=1. Similarly, for K=9, output will be same as that for K=2 and so on.
1 Like