Longest Substring Without Repeats

medium
Unit 1 · Hash Map0/3 to milestone

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