Find substrings that contain all vowels | C ++ program to find all substring that contain all vowels ; Returns true if x is vowel . ; Function to check whether a character is vowel or not ; Function to FindSubstrings of string ; set < char > hash ; To store vowels ; If current character is vowel then insert into hash , ; If all vowels are present in current substring ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isVowel ( char x ) { return ( x == ' a ' x == ' e ' x == ' i ' x == ' o ' x == ' u ' ) ; } void FindSubstring ( string str ) { int start = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( isVowel ( str [ i ] ) == true ) { hash . insert ( str [ i ] ) ; if ( hash . size ( ) == 5 ) cout << str . substr ( start , i - start + 1 ) << " ▁ " ; } else { start = i + 1 ; hash . clear ( ) ; } } } int main ( ) { string str = " aeoibsddaeiouudb " ; FindSubstring ( str ) ; return 0 ; }