Clean recursive python solution

  • 6
    def mergeTwoLists(self, l1, l2):
            :type l1: ListNode
            :type l2: ListNode
            :rtype: ListNode
            if not l1:
                return l2
            if not l2:
                return l1
            start = None    
            if l1.val < l2.val:
                start = l1;
       = self.mergeTwoLists(, l2)
                start = l2;
       = self.mergeTwoLists(l1,
            return start

Log in to reply

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