Calculate the prefix sum of special nodes
prefix [ i ] = int ( isSpecial ( s [ i ] , special ) ) NEW_LINE if ( i > 0 ) : NEW_LINE INDENT prefix [ i ] += prefix [ i - 1 ] NEW_LINE DEDENT for i in range ( n ) : NEW_LINE