Why is it wrong?


  • 0
    V
    class Solution:
    # @param A  a list of integers
    # @param m  an integer, length of A
    # @param B  a list of integers
    # @param n  an integer, length of B
    # @return nothing
    def merge(self, A, m, B, n):
        i = 0
        j = 0
        while i < len(A) and j < len(B):
            if A[i] <= B[j]:
                i += 1
            else:
                A.insert(i, B[j])
                i += 1
                j += 1
        
        if j < n:
            A += B[j:]

Log in to reply
 

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