Half of the test cases failed. What is wrong in my code?
Code: https://ide.codingblocks.com/s/590399
Linked List-K Append Problem
just do k = k%n… i think u would be getting tel bcoz k can we very large compared to n
u can also refer this https://ide.codingblocks.com/s/590407
Do you mean TLE error?
yes… what error are u getting while submitting?
hey, i got the correct output. Now the only doubt i have is, if ‘k’ is multiple of ‘N’, i am getting segmentation fault. Why?
so basically if k is a multiple of n then u dont have to do anything and simply return the original linked list… refer to my soln
I understood the logic. But in my code, if k is multiple of N, then why is it showing Seg fault? I tried to dry run, but according to me it should not show seg fault. Help me in understanding this, that because of which line in the code it is showing seg fault.
so that is what i am saying na… initially u just do k = k%n… if k comes out to be 0 then don’t do anything and simply return the head
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.