- What is merge sort?
Recursivelyto dissect nodes into a single node. Then
- Another knowledge is
how to find the middle node?
slowpointer. Fast pointers moves two nodes per time, but slow pointer moves once.
- The terminating condition is
fast.next && fast.next.next, targeting both
evennumber of nodes.
- For merging, use a
dummyHead, and another tmp to move around. The result should be the
head of a linked list, return the list after sorting it in
Input: head = [4,2,1,3]