Linked - list k append

In the note here k can be greater than means like if we N=6 , k =8
so in this case if have to return the original LL

@Vikaspal When K>n, then answer would not be null, Count the linked list position in circular fashion.
Suppose linked list is 1->2->3 now we need to go to 5th then 1->2->3->1->2 (NOTE: Linked list it self is not circular)
This will basically make K=K%n
SO first make K=K%n and then solve
If this resolves your doubt mark it as resolved.

https://ide.codingblocks.com/s/237024 test case fail this is 0(N) right ?

@Abhinav2604 got ur point I know ur approach but how to interpret / explaine to another why are going the % here . can u give me the precise answer?

@Abhinav2604 it like we make the number smaller so it always less than n if we doing k = k%n that why?

one test case left after making it circular

@Vikaspal Appending a list of length n by its last n element will effectively make no changes in the list, so suppose K = r*n + x (x<n) we first append the list rn times now as I said before this will have effectively no change on the list , so we can skip these operations and directly append x elements
And
K%n = x
That is why we are taking mod.
If this resolves your doubt mark it as resolved. If not please provide the modified code.

K = r*n + x (x<n) can explain this equation please it didn’t get this . I understood that when we do the mod it will not going to affect anythings because the values we get also lies in the range

@Vikaspal Hey this equation is just for showing why taking mod works, we are counting in circular fashion, so multiples of n will make no change, r*n would make no change, that leaves x, so we just need to append x last elements at front
If this resolves your doubt mark it as resolved.

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.