Python question


  • 0
    L

    class Solution(object):
    def merge(self, nums1, m, nums2, n):

            if len(nums1)<m+n:
                return -1
            for i in range(n):
                nums1[m+i]=nums2[i]
            nums1=nums1[0:m+n]
            nums1.sort()
    

    I do not know why my answer is wrong?? please help me ,Thank you!


  • 1
    B

    The problem is this line

     nums1=nums1[0:m+n]
    

    You are creating a new variable which does not refer to the original nums1 anymore. Just remove that line and it should work.


Log in to reply
 

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