标签:and next object tco span 表头 style swap sel
1. 使用dummy node保存表头
2. cur -> head -> head.next -> p
1 class Solution(object): 2 def swapPairs(self, head): 3 """ 4 :type head: ListNode 5 :rtype: ListNode 6 """ 7 dummy = cur = ListNode(0) 8 dummy.next = head 9 10 while head != None and head.next != None: 11 p = head.next.next 12 cur.next = head.next 13 cur.next.next = head 14 head.next = p 15 cur = head 16 head = p 17 18 return dummy.next
Leetcode #24. Swap nodes in pairs
标签:and next object tco span 表头 style swap sel
原文地址:http://www.cnblogs.com/lettuan/p/6105944.html