Given a string s of lowercase letters, we need to find the longest substring length that contain (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 current number of vowels in the string. If we see a character that is not vowel, we reset count to 0. But before resetting we update 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.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Longest substring having K distinct vowels
- Length of the smallest substring which contains all vowels
- Encrypt string with product of number of vowels and consonants in substring of size k
- Longest Ordered Subsequence of Vowels
- Longest Subsequence of a String containing only vowels
- Length of longest common subsequence containing vowels
- Longest Palindromic Substring | Set 1
- Longest Common Substring | DP-29
- Longest substring with count of 1s more than 0s
- Longest Non-palindromic substring
- Longest Palindromic Substring | Set 2
- Longest repeating and non-overlapping substring
- Longest substring such that no three consecutive characters are same
- Length of the longest substring with equal 1s and 0s
- Print the longest common substring
Improved By : nitin mittal