leetcodePython3/class/List.py
def reorderList(self, head: ListNode) -> None:
        """
        Do not return anything, modify head in-place instead.
        """
        if head is None or head.next is None :return
        slow = head
        faster = head
        #分隔链表
        while slow.next and  faster.next:
            if faster.next.next is None:
                break
            else:
                slow = slow.next
                faster = faster.next
                faster = faster.next
        currentNode = slow.next

        last = None#翻转后边的链表
        while currentNode:
            nexNode = currentNode.next
            currentNode.next = last
            last = currentNode
            currentNode = nexNode
        slow_new1 = head

        while True:#拼接链表
            nextNode = slow_new1.next
            next_last = last.next
            last.next = nextNode
            slow_new1.next = last
            slow_new1 = nextNode
            if next_last is None:#最后一个节点的next置None
                slow_new1.next = None
                break
            last = next_last
            #148排序链表

        Do not return anything, modify head in-place instead.
        
Do not return anything, modify head in-place instead.
Do not return anything modify head in - place instead .
def reorderList(self, head: ListNode) -> None:
        if head is None or head.next is None :return
        slow = head
        faster = head
        while slow.next and  faster.next:
            if faster.next.next is None:
                break
            else:
                slow = slow.next
                faster = faster.next
                faster = faster.next
        currentNode = slow.next
        last = None
        while currentNode:
            nexNode = currentNode.next
            currentNode.next = last
            last = currentNode
            currentNode = nexNode
        slow_new1 = head
        while True:
            nextNode = slow_new1.next
            next_last = last.next
            last.next = nextNode
            slow_new1.next = last
            slow_new1 = nextNode
            if next_last is None:
                slow_new1.next = None
                break
            last = next_last
def reorderList ( self , head : ListNode ) -> None : if head is None or head . next is None : return slow = head faster = head while slow . next and faster . next : if faster . next . next is None : break else : slow = slow . next faster = faster . next faster = faster . next currentNode = slow . next last = None while currentNode : nexNode = currentNode . next currentNode . next = last last = currentNode currentNode = nexNode slow_new1 = head while True : nextNode = slow_new1 . next next_last = last . next last . next = nextNode slow_new1 . next = last slow_new1 = nextNode if next_last is None : slow_new1 . next = None break last = next_last
Do not return anything, modify head in-place instead.
Do not return anything modify head in - place instead .
"""
        Do not return anything, modify head in-place instead.
        """ #分隔链表 #翻转后边的链表 #拼接链表 #最后一个节点的next置None #148排序链表
self
head
ListNode