To store frequency of 4 characters
Dictionary < char , int > mp = new Dictionary < char , int > ( ) ; if ( mp . ContainsKey ( A [ i ] ) ) mp [ A [ i ] ] ++ ; else mp [ A [ i ] ] = 1 ; if ( mp . ContainsKey ( A [ n - i - 1 ] ) ) mp [ A [ n - i - 1 ] ] ++ ; else mp [ A [ n - i - 1 ] ] = 1 ; if ( mp . ContainsKey ( B [ i ] ) ) mp [ B [ i ] ] ++ ; else mp [ B [ i ] ] = 1 ; if ( mp . ContainsKey ( B [ n - i - 1 ] ) ) mp [ B [ n - i - 1 ] ] ++ ; else mp [ B [ n - i - 1 ] ] = 1 ; int sz = mp . Count ;