Longest Complete Vowel Stretch
s holds only the five vowels a, e, i, o and u. A stretch of consecutive letters is complete when it contains every one of the five vowels at least once and its letters never go backwards in the alphabet: reading it from left to right, all of its as come first, then its es, then its is, then its os, then its us.
Return the length of the longest complete stretch, or 0 if s has none. Letters may repeat any number of times inside a stretch.
Example 1
The stretch aaaaeiiiiouuu (positions 7 to 19) has all five vowels in order and is the longest such stretch.
Example 2
The letters are in order but there is no i, so no stretch is complete.
Constraints
0 <= len(s) <= 60shas only the letters a, e, i, o and u
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Two pointers problems
- Longest Ones After Deleting OneMedium
- Longest Palindromic SubstringMedium
- Longest Repeating Character ReplacementMedium
- Longest Stretch With No Letter ThriceMedium
- Longest Substring Without Repeating CharactersMedium
- Max Consecutive Ones With FlipsMedium
- Minimum Size Subarray SumMedium
- Overlaps of Two SchedulesMedium