Function to check whether any of the string have a repeated character
function haveRepeated ( S1 , S2 ) { var freq = Array ( 26 ) . fill ( 0 ) ; S1 . forEach ( i => { if ( freq [ i - ' ' ] > 0 ) return true ; freq [ i - ' ' ] ++ ; } ) ; for ( var i = 0 ; i < 26 ; i ++ ) freq [ i ] = 0 ; S2 . split ( ' ' ) . forEach ( i => { if ( freq [ i - ' ' ] > 0 ) return true ; freq [ i - ' ' ] ++ ; } ) ; return false ; }