Question is to append last k elements to the front and my solution is : https://ide.codingblocks.com/s/202678
3 testcases are failing pls tell me what’s wrong?
LinkedList K Append
@YashJ,
https://ide.codingblocks.com/s/202696 Corrected code.
Your error was that you were not doing k = k%N.
In case the value of k>N, we will do k = k%N
Example:
k=10, N=7.
Now in this case, the list will be appended entirely once i.e. it will become the same list again and then we will append remaining elements (3 in this case). This case remains the same, say k=17 and N=7 the answer will remain the same.