Python Solution (Same as Partition List)

  • 0

    I just reused the solution of Partition List problem present here.
    Sharing as original solution was easier to remember and two birds with one stone.

    class Solution(object):
        def oddEvenList(self, head):
            :type head: ListNode
            :rtype: ListNode
            lefthead = left = ListNode(0)
            righthead = right = ListNode(0)
            count = 1
            while head:
                if count%2:
           = head
                    left =
           = head
                    right =
   = None

Log in to reply

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