Python manipulated by values


  • 0

    '''
    class Solution(object):
    def partition(self, head, x):
    """
    :type head: ListNode
    :type x: int
    :rtype: ListNode
    """
    if head is None:
    return head
    node = head
    temp1 = []
    temp2 = []
    while node is not None:
    if node.val < x:
    temp1.append(node.val)
    else:
    temp2.append(node.val)
    node = node.next
    node = head
    for i in temp1:
    node.val = i
    node = node.next
    for i in temp2:
    node.val = i
    node = node.next
    return head
    '''


Log in to reply
 

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