I found this question at
http://www.programcreek.com/2015/03/leetcode-odd-even-linked-list-java/.
I debug the soltion and understood a bit. Here is the code:
My problem is I do not understand two parts:
1. Why ListNode connectNode = head.next; needed?
2. Why p1.next = connectNode; needed?
If we are changing the nodes towards the while loop than why need to connect them using connectNode. Are not they already connected?
Is there any better approach?