class Solution:
    def oddEvenList(self , head ):
        res = ListNode(0)
        p = res
        i = 1
        s1 = []
        s2 = []
        while head is not None:
            if i % 2 != 0:
                s1.append(head.val)
                head = head.next
            else:
                s2.append(head.val)
                head = head.next
            i += 1
        for item in s1 + s2:
            p.next = ListNode(item)
            p = p.next

        return res.next

偷了个懒处理了一下,最近在备考算法题,python因为没有单向链表所以实现上反而不好实现 alt