Check if a string can be split into two substrings with equal number of vowels | JavaScript program for the above approach Function to check if any character is a vowel or not ; Lowercase vowels ; Uppercase vowels ; Otherwise ; Function to check if string S can be split into two substrings with equal number of vowels ; Stores the count of vowels in the string S ; Traverse over the string ; If S [ i ] is vowel ; Stores the count of vowels upto the current index ; Traverse over the string ; If S [ i ] is vowel ; If vowelsTillNow and totalVowels are equal ; Otherwise ; Driver Code
function isVowel ( ch ) { if ( ch === " " ch === " " ch === " " ch === " " ch === " " ) return true ; if ( ch === " " ch === " " ch === " " ch === " " ch === " " ) return true ; return false ; } function containsEqualStrings ( S ) { var totalVowels = 0 ; for ( var i = 0 ; i < S . length ; i ++ ) { if ( isVowel ( S [ i ] ) ) totalVowels ++ ; } var vowelsTillNow = 0 ; for ( var i = 0 ; i < S . length ; i ++ ) { if ( isVowel ( S [ i ] ) ) { vowelsTillNow ++ ; totalVowels -- ; if ( vowelsTillNow === totalVowels ) { return " " ; } } } return " " ; } var S = " " ; document . write ( containsEqualStrings ( S ) ) ;