My python solution--only swap values

  • -6
    class Solution(object):
        def swapPairs(self, head):
            :type head: ListNode
            :rtype: ListNode
            if not head or not head
            p = head
            while p and
                p.val, =, p.val
                p =
            return head

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.