Last updated
Was this helpful?
Last updated
Was this helpful?
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.
You should preserve the original relative order of the nodes in each of the two partitions.
For example,
Given1->4->3->2->5->2
andx= 3,
return1->2->2->4->3->5
.
分析
4个指针,2个左右dummy,2个指向他们的指针。
最后右指针结尾一定要置空!!!