Given a string return all possible subsequences which start with vowel and end with consonant. A String is a subsequence of a given String, that is generated by deleting some character of a given string without changing its order.
Input : 'abc' Output : ab, ac, abc Input : 'aab' Output : ab, aab
Question Source: Yatra.com Interview Experience | Set 7
Explanation of the Algorithm:
Step 1: Iterate over the entire String Step 2: check if the ith character for vowel Step 3: If true iterate the string from the end, if false move to next iteration Step 4: check the jth character for consonent if false move to next iteration if true perform the following Step 5: Add the substring starting at index i and ending at index j to the hastset. Step 6: Iterate over the substring drop each character and recur to generate all its subString
[ef, ab, ac, aef, abc, abf, af, acf, abcef, abcf, acef, abef]
This article is contributed by Sumit Ghosh. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Alternate vowel and consonant string
- Lexicographically first alternate vowel and consonant string
- Count of N size strings consisting of at least one vowel and one consonant
- Program to find if a character is vowel or Consonant
- Count of adjacent Vowel Consonant Pairs
- Count characters to be shifted from the start or end of a string to obtain another string
- Program to count vowels, consonant, digits and special characters in string.
- Given a binary string, count number of substrings that start and end with 1.
- Different substrings in a string that start and end with given strings
- Replace every consonant sequence with its length in the given string
- Minimize cost to replace all the vowels of a given String by a single vowel
- Sub-strings that start and end with one character and have at least one other
- Number of substrings that start with "geeks" and end with "for"
- Program to build a DFA to accept strings that start and end with same character
- Count subsequences in first string which are anagrams of the second string
- Python program to check if given string is vowel Palindrome
- Check if the given string is vowel prime
- Replace every vowels with lexicographically next vowel in a String
- Count the nodes of the tree whose weighted string contains a vowel
- Print all subsequences of a string