Traverse the string S
for i in range ( N ) : NEW_LINE INDENT if ( S [ i ] in freq ) : NEW_LINE INDENT freq [ S [ i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT freq [ S [ i ] ] = 1 NEW_LINE DEDENT DEDENT