Given 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}.
本文详细阐述了如何通过快慢指针找到链表中点、反转后半部分链表,并将其与前半部分交替链接,实现链表的重组。通过实例演示了从原始链表到重组链表的完整过程。
Given 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}.
758
730
730

被折叠的 条评论
为什么被折叠?