My code gives run error in 3 test cases I tried my best but I cant figure out what i am doing wrong.Please Help Sir/Ma’am https://ide.codingblocks.com/s/180462
LinkedList -K Append Problem
take into consideration the case when k>n
Still not working ma’am
if k>n i.e. number of elements to be appended exceeds n, use k = k%n. Because after n appending operations all the elements will be back to their original position.
So in this case:
7
1 2 2 1 8 5 6
11
After 7 times, the linked list will be back to its original position. And then we have to do the appending for 4 times again.
just add
k=k%n;
before the line
head = cal(head, k);