Why can not use list.append function?


  • 0
    6
    `def merge(self, A, m, B, n):
        i, j = 0, 0
        while i<m and j<n:
            if A[i] < B[j] :
                i+=1
            else:
                A.insert(i, B[j])
                i, j, m = i+1, j+1, m+1
        while j < n:
            A.append(B[j])   # WA if use append(), but AC if insert()
            j+=1`
    

    could you tell me which version of python is working?


Log in to reply
 

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