Find substrings that contain all vowels | CPP 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 ; Outer loop picks starting character and inner loop picks ending character . ; If current character is not vowel , then no more result substrings possible starting from str [ i ] . ; If vowel , then we insert it in 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 n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { if ( isVowel ( str [ j ] ) == false ) break ; hash . insert ( str [ j ] ) ; if ( hash . size ( ) == 5 ) cout << str . substr ( i , j - i + 1 ) << " ▁ " ; } hash . clear ( ) ; } } int main ( ) { string str = " aeoibsddaeiouudb " ; FindSubstring ( str ) ; return 0 ; }