MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / oddEvenList

Method oddEvenList

Array/OddEvenLinkedList.py:45–65  ·  view source on GitHub ↗

:type head: ListNode :rtype: ListNode

(self, head)

Source from the content-addressed store, hash-verified

43
44class Solution(object):
45 def oddEvenList(self, head):
46 """
47 :type head: ListNode
48 :rtype: ListNode
49 """
50 if not head:
51 return head
52 odd = head
53 even = head.next
54 even_head = even
55
56 while odd.next and even.next:
57 odd.next = odd.next.next
58 even.next = even.next.next
59
60 odd = odd.next
61 even = even.next
62
63 odd.next = even_head
64
65 return head
66

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected