# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution(object):
def swapPairs(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
def ExchangeNode(head):
l4=ListNode(0,head)
l5=l4
while l4.next!=None and l4.next.next!=None:
l3=l4.next.next.next
l2=l4.next.next
l1=l4.next
l4.next.next=l3
l4.next=l2
l4.next.next=l1
l4=l4.next.next
return l5.next
return ExchangeNode(head)
链表操作的题目,细心总能做对