题目:
题解:
class Solution:def partition(self, head: Optional[ListNode], x: int) -> Optional[ListNode]:sml_dummy, big_dummy = ListNode(0), ListNode(0)sml, big = sml_dummy, big_dummywhile head:if head.val < x:sml.next = headsml = sml.nextelse:big.next = headbig = big.nexthead = head.nextsml.next = big_dummy.nextbig.next = Nonereturn sml_dummy.next