def repeat_and_missing_number(A):
    r = []
    sum_l = 0
    n = len(A)
    A = list(A)
    # calculate repeating number by O(N)
    for i in range(n):
        sum_l += abs(A[i])
        if A[abs(A[i])-1] > 0:
            A[abs(A[i])-1] = -A[abs(A[i])-1]
        else:
            r.append(abs(A[i]))

    # calculate sum of the list, n*(n+1)//2
    # actual sum of 1 to N - (above sum -repeating no) = missing number
    sum_n = n*(n+1)//2
    r.append(sum_n-(sum_l-r[0]))
    return r

d6aba6d1322824cf8d5fb402b7b951889e25c815
<mask token>

def repeat_and_missing_number(A):
    r = []
    sum_l = 0
    n = len(A)
    A = list(A)
    for i in range(n):
        sum_l += abs(A[i])
        if A[abs(A[i]) - 1] > 0:
            A[abs(A[i]) - 1] = -A[abs(A[i]) - 1]
        else:
            r.append(abs(A[i]))
    sum_n = n * (n + 1) // 2
    r.append(sum_n - (sum_l - r[0]))
    return r

def repeat_and_missing_number(A):
    r = []
    sum_l = 0
    n = len(A)
    A = list(A)
    # calculate repeating number by O(N)
    for i in range(n):
        sum_l += abs(A[i])
        if A[abs(A[i])-1] > 0:
            A[abs(A[i])-1] = -A[abs(A[i])-1]
        else:
            r.append(abs(A[i]))

    # calculate sum of the list, n*(n+1)//2
    # actual sum of 1 to N - (above sum -repeating no) = missing number
    sum_n = n*(n+1)//2
    r.append(sum_n-(sum_l-r[0]))
    return r
