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 ; To store vowels 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
using System ; using System . Collections . Generic ; public class GFG { public static bool isVowel ( char x ) { return ( x == ' a ' x == ' e ' x == ' i ' x == ' o ' x == ' u ' ) ; } public static void findSubstring ( string str ) { HashSet < char > hash = new HashSet < char > ( ) ; 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 . Add ( str [ j ] ) ; if ( hash . Count == 5 ) { Console . Write ( str . Substring ( i , ( j + 1 ) - i ) + " ▁ " ) ; } } hash . Clear ( ) ; } } public static void Main ( string [ ] args ) { string str = " aeoibsddaeiouudb " ; findSubstring ( str ) ; } }