LeetCode-24-Swap-Nodes-in-Pairs 链表递归水题
2017-09-11 14:06
399 查看
# 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:return None if head.next==None:return head nextHead=self.swapPairs(head.next.next) h=head.next h.next=head h.next.next=nextHead return h
相关文章推荐
- LeetCode 24 Swap Nodes in Pairs (链表 递归&&非递归)
- LeetCode - 24 - Swap Nodes in Pairs(交换链表结点)
- [Leetcode 24 链表]Swap Nodes in Pairs
- LeetCode-24 Swap Nodes in Pairs(链表中按要求交换节点)
- [leetcode 24]Swap Nodes in Pairs-----成对翻转链表中的节点
- LeetCode-24-Swap Nodes in Pairs(链表)-Medium
- [leetcode] 24 Swap Nodes in Pairs(交换链表相邻结点)
- 【leetcode】【单链表】【24】Swap Nodes in Pairs
- 【leetcode】【单链表】【24】Swap Nodes in Pairs
- LeetCode | Swap Nodes in Pairs(将链表中的元素两两交换)
- [leetcode] 【链表】24. Swap Nodes in Pairs
- 【LeetCode-24】Swap Nodes in Pairs(C++)
- leetcode 24: Swap Nodes in Pairs
- LeetCode-24. Swap Nodes in Pairs
- leetcode-24 Swap Nodes in Pairs
- LeetCode-25-Reverse-Nodes-in-k-Group 链表递归水题
- LeetCode(24)--Swap Nodes in Pairs
- leetcode_24_Swap Nodes in Pairs
- leetcode 24 Swap Nodes in Pairs
- Leetcode 24. Swap Nodes in Pairs