Loop to find the frequencies subsequence of length 2
for ( i = 0 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { string temp = " " ; temp += s [ i ] ; temp += s [ j ] ; if ( freq . ContainsKey ( temp ) ) freq [ temp ] ++ ; else freq [ temp ] = 1 ; } } int answer = int . MinValue ;