map is used to store character frequencies
var m = new Map ( ) ; for ( i = 0 ; i < s . length ; i ++ ) { if ( m . has ( s [ i ] ) ) { m . set ( s [ i ] , m . get ( s [ i ] ) + 1 ) ; } else { m . set ( s [ i ] , 1 ) ; } } var result = 0 ; var flag = 0 ;