题目:
题解:
func partition(head *ListNode, x int) *ListNode {
small := &ListNode{}
smallHead := small
large := &ListNode{}
largeHead := large
for head != nil {
if head.Val < x {
small.Next = head
small = small.Next
} else {
large.Next = head
large = large.Next
}
head = head.Next
}
large.Next = nil
small.Next = largeHead.Next
return smallHead.Next
}