思路:变成数组操作
def oddEvenList(self , head: ListNode) -> ListNode: # write code here p = head nums = [] while p: nums.append(p.val) p = p.next p = head nums_a = [] nums_b = [] for i in range(len(nums)): if i % 2 == 0: nums_a.append(nums[i]) else: nums_b.append(nums[i]) num = nums_a + nums_b for i in range(len(num)): p.val = num[i] p = p.next return head 标签:奇偶,head,nums,链表,num,重排,append From: https://www.cnblogs.com/ailie/p/16942121.html