It use merge sort to deal with the problem:
- Use fast slow pointers to traverse the list and find the mid-point at once(move 1 step for slow, 2 step for fast)
- before merge, break the slow connect, merge it.
- in merge, do not directly assign selected element to merge, use swap() to swap the head of left and right, then directly assign left to merge. SO after that all elements in right will larger than left.(think about we need to actually swap the element not value)
Error:
5. Do not trully understand what is merge sort: 1) merge it until single elements, 2) merge it.
So, we need to call the function recursively with left list and right list.
6. When meet single element, return directly.