Can not pass the input [], [1], but get the expected on my PC.


  • 0
    K
    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 < m and j < n:
                if A[i] < B[j]:
                    i += 1
                else:
                    A.insert(i, B[j])
                    m += 1
                    i += 1
                    j += 1
            if j < n:
                A.extend(B[j:])

Log in to reply
 

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