class (object): def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ if not head or not head.next: return head cur = head next = head.next next_head = head.next.next next.next = cur cur.next = self.swapPairs(next_head) return next
|
近期评论