Frequency of single character can be possibly changed , so change its parity
for ( int j = 0 ; j < 26 ; j ++ ) { vector < int > changedCount = a ; if ( a [ j ] == 0 ) changedCount [ j ] = 1 ; else changedCount [ j ] = 0 ; ans += mp [ changedCount ] ; } mp [ a ] ++ ; } return ans ; }