Count pair of strings whose concatenation has every vowel | Java program for the above approach ; Function to return the count of all concatenated String with each vowel at least once ; Concatenating all possible pairs of String ; Creating an array which checks , the presence of each vowel ; Checking for each vowel by traversing the concatenated String ; Checking if all the elements are set in vowel [ ] ; Check if all vowels are present or not ; Return the final count ; Driver Code ; Given array of Strings ; Function Call
import java . util . * ; class GFG { static int good_pair ( String str [ ] , int N ) { int countStr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { String res = str [ i ] + str [ j ] ; int vowel [ ] = new int [ 5 ] ; for ( int k = 0 ; k < res . length ( ) ; k ++ ) { if ( res . charAt ( k ) == ' a ' ) vowel [ 0 ] = 1 ; else if ( res . charAt ( k ) == ' e ' ) vowel [ 1 ] = 1 ; else if ( res . charAt ( k ) == ' i ' ) vowel [ 2 ] = 1 ; else if ( res . charAt ( k ) == ' o ' ) vowel [ 3 ] = 1 ; else if ( res . charAt ( k ) == ' u ' ) vowel [ 4 ] = 1 ; } int temp = 0 ; for ( int ind = 0 ; ind < 5 ; ind ++ ) { if ( vowel [ ind ] == 1 ) temp ++ ; } if ( temp == 5 ) countStr ++ ; } } return countStr ; } public static void main ( String [ ] args ) { String arr [ ] = { " aaweiolkju " , " oxdfgujkmi " } ; int N = arr . length ; System . out . print ( good_pair ( arr , N ) ) ; } }