4 lines python beat 80%


  • 0
    X
    from bisect import insort                                                        
    class Solution(object):                                                          
        def merge(self, nums1, m, nums2, n):                                         
            """                                                                      
            :type nums1: List[int]                                                   
            :type m: int                                                             
            :type nums2: List[int]                                                   
            :type n: int                                                             
            :rtype: void Do not return anything, modify nums1 in-place instead.      
            """                                                                                          
            tempnums1,nums2=nums1[:m],nums2[:n]                                      
            [insort(tempnums1,num) for num in nums2]                                 
            nums1[:] = tempnums1  
    

Log in to reply
 

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