create map of banned words
for ( int i = 0 ; i < S2 . Length ; i ++ ) { String s = " " ; while ( i < S2 . Length && S2 [ i ] != ' ▁ ' ) s += S2 [ i ++ ] ; if ( banned . ContainsKey ( s ) ) { var val = banned [ s ] ; banned . Remove ( s ) ; banned . Add ( s , val + 1 ) ; } else { banned . Add ( s , 1 ) ; } } Dictionary < String , int > result = new Dictionary < String , int > ( ) ; String ans = " " ; int freq = 0 ;