2つのソートされた配列をマージ(Pythonコード)


def merge(A, B):
    '''
             
      :
            i,j      ,    ,     A, B    
            A[i], B[j]     ,            ,        +1
                .

    Args:
        list A:       
        list B:       

    Returns:
        result:         
    '''

    #         
    result = []
    #   A,B         ,      0    
    i, j = 0, 0
    while iand jif A[i]1
        else:
            result.append(B[j])
            j += 1
    result += A[i:]
    result += B[j:]
    return result
A = [1,33]
B = [2,5,6]
print(merge(A, B))