Trains the technique from
LeetCode 1839Longest Substring Of All Vowels in OrderThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A wetland recorder listens all night and tags every call it hears with one of five letters: a, e, i, o, u. The tags are written down in the order the calls arrived, giving the string calls.
The five tags have a fixed ranking, a then e then i then o then u. A stretch is a run of consecutive tags from the log. A stretch is complete when both of these hold:
Return the number of calls in the longest complete stretch of calls. If the log holds no complete stretch, return 0.
Example 1
The tags arrive as the blocks `aa`, `ee`, `ii`, `oo`, `uu`. All five tags appear and no tag ranks below the tag before it, so the whole log of ten calls is one complete stretch.
Example 2
The last six tags read `a e i o u u`: all five tags appear and none ranks below its predecessor, so that stretch is complete and holds six calls. The opening `u` cannot belong to it, because the tag after it ranks lower.
Example 3
No call is ever tagged `u`, so no stretch holds all five tags.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def longest_complete_stretch(calls: str) -> int:public int longestCompleteStretch(String calls)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.