Longest Substring Without Repeating Characters

M · mediumPracticestringssliding-window

Given a string, find the length of the longest substring that has no repeating characters.

Input
abcabcbb
Output
3
Sliding window + HashSet. Expand right pointer; when duplicate found, shrink left pointer.
Longest substring without repeat: "abc" (length 3)
← Longest Common Subsequence (LCS)Matrix Addition →
Report an issue with this question