1.分成两个链表,超出时间限制了
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def partition(self, head, x):
"""
:type head: ListNode
:type x: int
:rtype: ListNode
"""
# 分成两个链表
smallHead=small=ListNode(-1)
largeHead=large=ListNode(-1)
while(head):