Longest Unique Run
Given a string text, return the length of the longest run of consecutive characters in which no character appears twice.
A run is a contiguous piece of the text: in "streetcar", "etcar" is a run, "stcar" is not.
Examples
"streetcar" → 5 ("etcar")
"zzzz" → 1 ("z")
"abcadefa" → 6 ("bcadef")Constraints
- The text is between 0 and 50,000 characters long: letters, digits, spaces and punctuation, but no emoji (Python and TypeScript count those differently).
- Aim for O(n): look at each character a constant number of times.
Console
›Run to see what your code prints
Run checks the 3 visible cases here, in your browser. Submit runs all 7 on the judge, 4 of them hidden, and measures how your solution scales.
Expected is the reference solution's answer, from the judge. An input that breaks the statement's other rules may get any answer.