clean python solution


  • 0
    def merge(self, nums1, m, nums2, n):
            nums1tail = m - 1
            nums1newtail = m + n -1
            nums2tail = n - 1
    
            while nums2tail >= 0:
                if nums1tail >= 0 and nums1[nums1tail] > nums2[nums2tail]:
                    nums1[nums1newtail] = nums1[nums1tail]
                    nums1tail -= 1
                else:
                    nums1[nums1newtail] = nums2[nums2tail]
                    nums2tail -= 1
                nums1newtail -= 1
    

Log in to reply
 

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