Javascript program to print all the strings that match the given pattern where every character in the pattern is uniquely mapped to a character in the dictionary
function check ( pattern , word ) { if ( pattern . length != word . length ) return false ; let ch = new Array ( 128 ) ; for ( let i = 0 ; i < 128 ; i ++ ) { ch [ i ] = 0 ; } let Len = word . length ; for ( let i = 0 ; i < Len ; i ++ ) { if ( ch [ pattern [ i ] . charCodeAt ( 0 ) ] == 0 ) { ch [ pattern [ i ] . charCodeAt ( 0 ) ] = word [ i ] ; } else if ( ch [ pattern [ i ] . charCodeAt ( 0 ) ] != word [ i ] ) { return false ; } } return true ; }