please check
3 test cases giving wrong answer, I have tested it
when k>n then dont return the same list.
lets suppose ip is 1 2 3 4 and k =5
it means is we have to append last 1 i.e. k%n
Ya the problem in code is, your are assigning prev->next=NULL but there can be chance that prev=NULL as initialized because the value of n==k