Stores running count of ' x ' starting from the end
countX = [ 0 ] * n ; NEW_LINE count = 0 ; NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT if ( str [ i ] == ' x ' ) : NEW_LINE INDENT count = count + 1 NEW_LINE DEDENT countX [ i ] = count NEW_LINE DEDENT