Longest Run Without Repeats
Talk it through out loud with your AI coach.
The problem
- medium
- Pro
Given a string, find the length of the longest stretch of consecutive characters in which no character appears twice. For example, in "abcabcbb" the answer is three. Explain your approach and its cost.
What a strong answer covers
- A window that grows and shrinks over the string.
- How to know instantly what's inside the window.
- What to do when a repeated character arrives.
- The cost compared with checking every substring.
Common mistake: Restarting the window from scratch after a repeat, which throws away useful work.
Knowing this is half of it. Saying it clearly out loud is the part the coach helps you practise.
Practise it out loud