https://leetcode.com/problems/swap-nodes-in-pairs/#/description
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def swapPairs(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if head == None or head.next == None: return head
org = head
headNext = head.next
while org:
orgNext = org.next
orgNext2 = orgNext.next
orgNext.next = org
if orgNext2 and orgNext2.next:
org.next = orgNext2.next
org = orgNext2
else:
org.next = orgNext2
break
return headNext