Reorder List || Partition List
Reorder ListQuestionGiven a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes’ values.
For example,
Given {1,2,3,4}, reorder it to {1,4,2,3}.
Analysis
将一个链表以中点分为两段 l1,l2,并将 l2 reverse
遍历两个链表,将第二半链表中的点依次插入第一个链表中
注意在遍历插入节
...