Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
You should preserve the original relative order of the nodes in each of the two partitions.
For example,
Given 1->4->3->2->5->2 and x =
3,
return 1->2->2->4->3->5.

本文介绍了一种链表分区算法的实现方法,通过使用两个临时头指针和对应的尾指针来构建小于和大于等于给定值x的节点分区,同时保持了原始节点间的相对顺序。
312

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



