Longest Substring Without Repeating Characters
Reported by candidates from Bloomberg's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
A hash map of last-seen indexes is the whole solution to this Bloomberg OA question, reported in February 2026. It's the classic longest substring without repeating characters problem, and the constraint of 10^5 characters rules out checking every substring. If you've seen it before, you'll finish fast. If you blank on the window logic, a brute force attempt will time out and you'll burn your clock. StealthCoder sits invisibly on your screen during the live assessment as a safety net, so if the sliding window won't come to you, the working solution does.
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 pattern is a sliding window, even though the hint says dynamic-programming. Keep a left pointer and a map from character to its most recent index. Walk the right pointer through the string. When the current character was seen at an index at or after left, jump left to that index plus one. Then update the map and track the max of right minus left plus 1. That's O(n) time and O(k) space, where k is the character set. The common pitfall is moving left backward. If the old index is before left, ignore it. Another trap is shrinking the window one step at a time with a set, which works but is clumsier. Test on "abba" because it breaks the naive jump. If you freeze during the live OA, StealthCoder is the hedge that hands you the clean version.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
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 Bloomberg's OA.
Bloomberg reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Longest Substring Without Repeating Characters FAQ
How hard is Longest Substring Without Repeating Characters really?+
It's a medium, but a friendly one. The idea is short once you know it: one pass, two pointers, and a map. Most failures come from off-by-one errors or moving the left pointer backward, not from the concept. Write it once from memory before the OA.
What's the trick to solving it in O(n)?+
Store each character's last seen index. When you hit a repeat inside the current window, move left to lastSeen + 1. Never move it back. The window then only grows forward, so every character is touched once and you avoid rechecking substrings.
Why does the input hint say dynamic programming?+
Some people frame it as the best substring ending at each index, which is a DP view. The standard solution is a sliding window, and both give the same O(n) answer. Use the window version, it's easier to code under pressure.
Which edge cases should I test?+
Try "abba", which catches a left pointer that moves backward. Try a single character, a string of all the same character like "bbbbb", and a string with all distinct characters. Also run a 10^5 length input mentally to confirm nothing is quadratic.
Is this pattern still asked at Bloomberg?+
It was reported for Bloomberg in February 2026, so yes, it's current. Sliding window with a hash map shows up constantly in string questions, so the same technique transfers to variants like at most K distinct characters.