No repeats
Type the longest run of characters you can without hitting the same key twice.
Write longestUnique(s): return the length of the longest substring (consecutive characters) of s that has no repeated character.
Use a sliding window. Call show(line) at each step with the string and the window in square brackets, for example "ab[cab]cbb", and the stage prints the window sliding.
Example: longestUnique("abcabcbb") returns 3, for "abc".
Tests you can see
longestUnique("abcabcbb")3longestUnique("bbbbb")1longestUnique("pwwkew")3
More tests are hidden. The server runs them all before a time counts.
Call show() while your code works and the run plays back here.
javascriptlongestUnique()
Tab indents · Cmd/Ctrl+Enter runs