Check if a string is the typed name of the given name | Check if the character is vowel or not ; Returns true if ' typed ' is a typed name given str ; Traverse through all characters of str . ; If current characters do not match ; If not vowel , simply move ahead in both ; Count occurrences of current vowel in str ; Count occurrences of current vowel in typed ; Driver code
function isVowel ( c ) { let vowel = " " ; for ( let i = 0 ; i < vowel . length ; ++ i ) { if ( vowel [ i ] == c ) { return true ; } } return false ; } function printRLE ( str , typed ) { let n = str . length , m = typed . length ; let j = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( str [ i ] != typed [ j ] ) { return false ; } if ( isVowel ( str [ i ] ) == false ) { j ++ ; continue ; } let count1 = 1 ; while ( i < n - 1 && str [ i ] == str [ i + 1 ] ) { count1 ++ ; i ++ ; } let count2 = 1 ; while ( j < m - 1 && typed [ j ] == str [ i ] ) { count2 ++ ; j ++ ; } if ( count1 > count2 ) { return false ; } } return true ; } let name = " " , typed = " " ; if ( printRLE ( name , typed ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }