class Solution(object):
def swapPairs(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
ans=ListNode(0)
res=ans
ans.next=head
while head and head.next:
p=head.next
head.next=p.next
ans.next=p
p.next=head
ans=head
head=head.next
return res.next
python leetcode 24. Swap Nodes in Pairs
猜你喜欢
转载自blog.csdn.net/Neekity/article/details/84864263
今日推荐
周排行