Longest Substring Without Repeats

medium
Checkpoint challenge
Solve this to show you know the material and jump straight to Unit 2. Everything before it counts as cleared.

Return the longest substring of s with no repeated characters. A substring is contiguous, unlike a subsequence.

If several substrings tie for longest, return the one that appears first. Your solution should run in O(n)O(n) time: one pass with a sliding window, not checking every substring.

Examples

longest_unique_substring("abcabcbb")   # "abc"
longest_unique_substring("pwwkew")     # "wke"
longest_unique_substring("")           # ""
#sliding-window#strings#hash-map2 visible + 3 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Longest Substring Without Repeats · TechGradify