Reduce the frequency of the current character and count by 1 , so that it cannot interfere with the calculations of the same elements present to the right of it .
if ( m . ContainsKey ( str [ i ] ) ) m [ str [ i ] ] = m [ str [ i ] ] - 1 ; count -- ; }