Function to generate the sum of indices
def sumOfIndices ( s ) : NEW_LINE INDENT N = len ( s ) NEW_LINE x = ( int ) ( math . ceil ( math . log ( N ) / math . log ( 2 ) ) ) NEW_LINE seg_size = 2 * pow ( 2 , x ) - 1 NEW_LINE segment = [ 0 ] * ( seg_size ) NEW_LINE count = 4 NEW_LINE DEDENT