Slide a window over the longest unique run
A window is a slice described by two indices. Grow it on the right one character at a time. When the new character is already inside, move the left edge just past its previous position instead of starting over.
last = {}
text = "abcab"
# at index 3, 'a' was seen at 0
# so left moves to 1Think before coding
Remember where each character was last seen. The left edge only moves forward, so each index enters and leaves the window once and the whole scan is linear. Take the maximum width after each step. Work through the example by hand before changing the starter. Decide what should happen for an empty input, a single value and a repeated value where those cases apply. The checks use several inputs so a hard-coded answer cannot stand in for the rule.
Your task
Write longest_unique(text) returning the length of the longest substring with no repeated character.
The explanation opens here once every check passes.