Insertion sort python solution

  • 0
    class Solution(object):
        def insertionSortList(self, head):
            if not head or not
                return head
            dummy = ListNode(None)
  , tail = head,
   = None
            while tail:
                pre, current, next = dummy,,
                while current:
                    if tail.val <= current.val:
              , = tail, current
                    pre, current = current,
          , = tail, None
                tail = next

Log in to reply

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