Check if two same sub | Function to check if similar subsequences occur in a string or not ; iterate and count the frequency ; counting frequency of the letters ; check if frequency is more than once of any character ; Driver Code
function check ( s , l ) { let freq = new Array ( 26 ) . fill ( 0 ) ; for ( let i = 0 ; i < l ; i ++ ) { freq [ s [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; } for ( let i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] >= 2 ) return true ; } return false ; } let s = " " ; let l = s . length ; if ( check ( s , l ) ) document . write ( " " ) ; else document . write ( " " ) ;