Count N | to keep the string in lexicographically sorted order use start index to add the vowels starting the from that index ; base case : if string length is 0 add to the count ; if last character in string is ' e ' add vowels starting from ' e ' i . e ' e ' , ' i ' , ' o ' , ' u ' ; decrease the length of string ; char arr [ 5 ] = { ' a ' , ' e ' , ' i ' , ' o ' , ' u ' } ; starting from index 0 add the vowels to strings
function countstrings ( n , start ) { if ( n == 0 ) { return 1 ; } let cnt = 0 ; for ( let i = start ; i < 5 ; i ++ ) { cnt += countstrings ( n - 1 , i ) ; } return cnt ; } function countVowelStrings ( n ) { return countstrings ( n , 0 ) ; } let n = 2 ; document . write ( countVowelStrings ( n ) ) ;