Short'n'Sweet Python Solution with O(1) memory

  • 0
    class Solution(object):
        def oddEvenList(self, head):
            if not head or not
                return head
            odd, even, h, tail = head,,, None
            while odd and even:
                tail = odd
                odd =
       = if odd else None
                even =
            tail = odd if odd else tail
   = h
            return head

Log in to reply

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