Given a string s of lowercase letters, we need to find the longest substring length that contains (a, e, i, o, u) only.
Input: s = "geeksforgeeks" Output: 2 Longest substring is "ee" Input: s = "theeare" Output: 3
The idea is to traverse the string and keep track of the current number of vowels in the string. If we see a character that is not a vowel, we reset count to 0. But before resetting we update the max count value which is going to be our result.
This article is contributed by Ajay Puri. 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.
- Longest substring having K distinct vowels
- Longest substring consisting of vowels using Binary Search
- Longest substring of vowels with no two adjacent alphabets same
- Longest Substring having equal count of Vowels and Consonants
- Find the number of words of X vowels and Y consonants that can be formed from M vowels and N consonants
- Encrypt string with product of number of vowels and consonants in substring of size k
- Length of the smallest substring which contains all vowels
- Lexicographically smallest K-length substring containing maximum number of vowels
- Length of longest common subsequence containing vowels
- Longest Ordered Subsequence of Vowels
- Longest Subsequence of a String containing only vowels
- Longest subsequence consisting of alternate vowels and consonants
- Find if a given string can be represented from a substring by iterating the substring “n” times
- Partition given string in such manner that i'th substring is sum of (i-1)'th and (i-2)'th substring
- Length of the largest substring which have character with frequency greater than or equal to half of the substring
- Minimum length of substring whose rotation generates a palindromic substring
- Length of the longest substring without repeating characters
- Longest Non-palindromic substring
- Longest Palindromic Substring | Set 1
- Longest Palindromic Substring | Set 2