Find substrings that contain all vowels | Java 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
import java . util . HashSet ; public class GFG { static boolean isVowel ( char x ) { return ( x == ' a ' x == ' e ' x == ' i ' x == ' o ' x == ' u ' ) ; } static void findSubstring ( String str ) { HashSet < Character > hash = new HashSet < Character > ( ) ; int n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { if ( isVowel ( str . charAt ( j ) ) == false ) break ; hash . add ( str . charAt ( j ) ) ; if ( hash . size ( ) == 5 ) System . out . print ( str . substring ( i , j + 1 ) + " ▁ " ) ; } hash . clear ( ) ; } } public static void main ( String [ ] args ) { String str = " aeoibsddaeiouudb " ; findSubstring ( str ) ; } }