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 firstname.lastname@example.org. 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.
- Longest substring having K distinct vowels
- Encrypt string with product of number of vowels and consonants in substring of size k
- Longest Ordered Subsequence of Vowels
- Length of longest common subsequence containing vowels
- Longest Common Substring | DP-29
- Longest substring with count of 1s more than 0s
- Longest Palindromic Substring | Set 1
- Longest Palindromic Substring | Set 2
- Longest Non-palindromic substring
- Length of the longest substring with equal 1s and 0s
- Length of the longest valid substring
- Longest substring such that no three consecutive characters are same
- Longest repeating and non-overlapping substring
- Longest equal substring with cost less than K
- Length of the longest substring that do not contain any palindrome
Improved By : nitin mittal