You are viewing a single comment's thread. Return to all comments →
def summingPieces(arr): D = 10 ** 9 + 7 n = len(arr) c = (pow(2, n, D) - 1) % D v = (arr[0] * c) % D for i in range(2, n + 1): c = (c + pow(2, n - i, D) - pow(2, i - 2, D)) % D v = (v + arr[i - 1] * c) % D return v
Seems like cookies are disabled on this browser, please enable them to open this website
Summing Pieces
You are viewing a single comment's thread. Return to all comments →