what is wrong with the code,its not working correctly on first k elements while it works fine on next k’s.
Linked list k reverse
there were two errors
- at line 28, instead of head->next = reverse(next, k); it should be head->next = reverse(current, k);
- at line 65, instead of directly calling reverse(head,k) you should have done head=reverse(head,k)
as the reverse function returns the head of reversed list so head in your main function should be updated as well
I have updated your code : https://ide.codingblocks.com/s/182544
1 Like