Python Solution Timeout

  • 0

    I don't understand why my solution timeout when assign a new pointer to head, could anyone help me with that?
    class Solution(object):
    def partition(self, head, x):
    :type head: ListNode
    :type x: int
    :rtype: ListNode
    hd1 = head1 = ListNode(0)
    hd2 = head2 = ListNode(0)
    cur = head
    while cur:
    if cur.val < x: = cur
    head1 =
    if head.val >= x: = cur

            cur = = None =

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.