Given a string str containing only alphabets, the task is to print the longest subsequence of the string str containing only vowels.
Input: str = “geeksforgeeks”
“eeoee” is the longest subsequence of the string containing only vowels.
Input: str = “HelloWorld”
“eeo” is the longest subsequence of the string containing only vowels.
- Traverse through the given string character by character.
- If the character is a vowel, append it to the resultant string.
- When the traversal completes, the required longest subsequence containing only vowels is stored in the resultant string.
Below is the implementation of the above approach:
Time Complexity: O(N)
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.
- Longest Ordered Subsequence of Vowels
- Length of longest common subsequence containing vowels
- Longest subsequence consisting of alternate vowels and consonants
- Find length of longest subsequence of one string which is substring of another string
- Longest Subsequence of a String containing only Consonants
- Longest subsequence of the form 0*1*0* in a binary string
- Longest subsequence with at least one character appearing in every string
- Longest substring of vowels
- Longest substring having K distinct vowels
- Longest substring of vowels with no two adjacent alphabets same
- Longest subsequence such that every element in the subsequence is formed by multiplying previous element with a prime
- Longest substring consisting of vowels using Binary Search
- Count maximum occurrence of subsequence in string such that indices in subsequence is in A.P.
- Check if a string can be converted to another string by replacing vowels and consonants
- Longest Zig-Zag Subsequence
- Longest subsequence with no 0 after 1
- Longest subsequence with a given AND value
- Longest subsequence with a given AND value | O(N)
- Longest Increasing Subsequence using BIT
- Longest Repeating Subsequence
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.