32. Longest Substring Without Repeating Characters
mediumAsked at PlaidFind the length of the longest substring with no repeated characters. Plaid asks this as a sliding-window baseline before harder webhook-deduplication-window problems.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Plaid loops.
- Glassdoor (2025)— Plaid SWE II OA — sliding window classic.
- Blind (2026)— Plaid backend onsite.
Problem
Given a string s, find the length of the longest substring without repeating characters.
Constraints
0 <= s.length <= 5 * 10^4s consists of English letters, digits, symbols and spaces.
Examples
Example 1
s = "abcabcbb"3Explanation: The answer is "abc", with the length of 3.
Example 2
s = "bbbbb"1Example 3
s = "pwwkew"3Approaches
1. Brute force check every substring
Try every (i, j) pair; check if s[i..j] has duplicates.
- Time
- O(n^3)
- Space
- O(n)
function lengthOfLongestSubstring(s) {
let best = 0;
for (let i = 0; i < s.length; i++) {
for (let j = i; j < s.length; j++) {
if (new Set(s.slice(i, j + 1)).size === j - i + 1) best = Math.max(best, j - i + 1);
}
}
return best;
}Tradeoff: Cubic. Don't ship.
2. Sliding window with last-seen map
Expand right pointer. When you hit a repeat, jump left to one past the previous occurrence. Track best length.
- Time
- O(n)
- Space
- O(k) where k is alphabet
function lengthOfLongestSubstring(s) {
const last = new Map();
let left = 0, best = 0;
for (let right = 0; right < s.length; right++) {
const c = s[right];
if (last.has(c) && last.get(c) >= left) {
left = last.get(c) + 1;
}
last.set(c, right);
best = Math.max(best, right - left + 1);
}
return best;
}Tradeoff: Linear time. The 'last.get(c) >= left' check is critical — without it, a stale entry from before the window pulls left backward.
Plaid-specific tips
Plaid grades this on whether the window stays monotonic — left only moves forward. Bonus signal: mention 'this is the same shape as a webhook-dedup window where we keep only events from the last 60s; when a duplicate arrives, the window jumps past the previous occurrence.'
Common mistakes
- Setting left = last.get(c) + 1 unconditionally — pulls left backward if c was last seen before the current window.
- Using a Set + slow rebuilds — O(n^2).
- Forgetting that right - left + 1 is the current window length.
Follow-up questions
An interviewer at Plaid may pivot to one of these next:
- Longest substring with at most k distinct characters.
- Longest substring with exactly k distinct characters.
- Minimum window substring (LC 76) — harder, two-character constraint.
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why does left only move forward?
Because once a character is removed from the window, the window cannot recover it without violating the no-duplicate constraint. Monotonic left is the optimization.
What's the connection to webhook dedup?
Both maintain a window of recently seen items. When a duplicate arrives, you reset the window boundary past the duplicate. Identical algorithm.
Practice these live with InterviewChamp.AI
Drill Longest Substring Without Repeating Characters and other Plaid interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →