Longest Substring Without Repeating Characters
Reported by candidates from Akuna Capital's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The edge case that kills naive solutions on this one is the repeat that sits outside your current window. Akuna Capital had candidates reporting Longest Substring Without Repeating Characters in September 2026, and it looks easy until a string like "abba" shows up. With s up to 10^5 characters, brute force over every substring dies on size alone. The pattern is a sliding window with a hash map of last-seen indexes. If you've seen it before, you're fine. If you blank under the clock, StealthCoder is the invisible safety net running during the live OA. Know the trick first, though.
The problem
Given a string s, return the length of its longest contiguous substring that contains no repeated characters. Function lengthOfLongestSubstring(s: String) → int Examples Example 1 s = "abcabcbb" return = 3 "abc" is a longest substring without repeated characters, so the answer is 3. Example 2 s = "bbbbb" return = 1 Every substring with distinct characters contains at most one b. Constraints 1 <= s.length <= 10^5. s contains English letters, digits, and common symbols.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is two pointers and a map from character to its last seen index. Walk the right pointer across the string. When the current character was last seen at an index inside the window, jump the left pointer to that index plus one. Then record the window length as right minus left plus one. The classic pitfall is moving left backward. In "abba", when you hit the final a, its old index is 0, but left is already at 2. Always take the max of left and lastSeen plus one. A second pitfall is shrinking the window one step at a time with a set, which works but is clumsier. Both approaches run in O(n) time, and the map needs O(min(n, alphabet)) space. The hint says dynamic-programming, but this is really a sliding window. If the clock is eating you in the live OA, StealthCoder can hand you the clean version while you check your edge cases.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Longest Substring Without Repeating Characters cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as longest substring without repeating characters. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Akuna Capital's OA.
Akuna Capital reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Longest Substring Without Repeating Characters FAQ
How hard is this problem really for the Akuna Capital OA?+
It's a standard medium. The logic is short, but the bugs are subtle. Most failures come from the stale-index case like "abba" or from off-by-one window lengths. If you can code the sliding window cleanly in ten minutes, you're in good shape.
What's the trick to solving it in O(n)?+
Keep a map of each character's last seen index and a left pointer. When you see a repeat, move left to max(left, lastSeen + 1). Update the best length each step. One pass, no re-scanning, no nested loops over substrings.
Why does "abba" break so many solutions?+
At the second a, the map says a was last seen at index 0. But your window already starts at index 2 because of the repeated b. If you blindly set left to 1, the window grows backward and includes a repeated b. The max() guard fixes this.
Is this sliding window or dynamic programming?+
Sliding window with a hash map is the standard answer. You can frame it as DP, since the best substring ending at each index depends on the previous one, but nobody expects a DP table here. Write the two-pointer version and explain the invariant.
How do I prepare for this in 48 hours?+
Code it from scratch twice, once with a set and once with a last-seen map. Test "abba", "bbbbb", a single character, and a string with all unique characters. Then do two other sliding window problems so the pattern feels automatic.