MCPcopy Create free account
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / swapPairs2

Method swapPairs2

leetcode/24. Swap Nodes in Pairs.py:34–43  ·  view source on GitHub ↗
(self, head)

Source from the content-addressed store, hash-verified

32 return head
33 # recursion
34 def swapPairs2(self, head):
35 if not head or not head.next:
36 return head
37
38 first, second = head, head.next
39 third = second.next
40 head = second
41 second.next = first
42 first.next = self.swapPairs(third)
43 return head

Callers

nothing calls this directly

Calls 1

swapPairsMethod · 0.95

Tested by

no test coverage detected