Reported September 2026
Wexsliding window

Longest Substring Without Repeating Characters

Reported by candidates from Wex's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Wex OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt at this Wex question is shrinking the window wrong, and it was reported in September 2026. It's Longest Substring Without Repeating Characters, and the input is a printable ASCII string up to 50,000 characters. Brute force over every substring dies on the larger inputs. The real answer is a sliding window with a map of last-seen positions. If you blank when the OA timer starts, StealthCoder sits invisibly on your screen as a safety net and hands you the window logic. Know the trick anyway. It's about ten lines.

The problem

You are given a string s consisting of printable ASCII characters.
Return the length of the longest substring of s that contains no repeated character.
The empty string has length 0.

Function
lengthOfLongestSubstring(s: String) → int

Examples
Example 1
s = "abcabcbb"
return = 3
The substring abc has length 3 and no repeated character. Longer windows such as abca repeat a.
Example 2
s = "bbbbb"
return = 1
Every character is b, so the longest non-repeating substring has length 1.
Example 3
s = "pwwkew"
return = 3
The substring wke has length 3. The answer must be a contiguous substring, so pwke is not valid.

Constraints
0 <= s.length <= 5 * 10^4.
s contains only printable ASCII characters.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Keep two pointers, left and right, and a map from character to its last index. Move right one step at a time. If the current character was seen at an index at or after left, jump left to that index plus one. Then record the new index and update the best length as right - left + 1. The classic pitfall is moving left backward. A stale map entry from before the window can pull left back and give a wrong answer, so always take the max of left and lastSeen + 1. Another trap is resetting the whole window on a repeat instead of sliding it. The hinted dynamic-programming label is a stretch. This is a sliding window with O(n) time and O(1) space, since the alphabet is bounded ASCII. Test pwwkew by hand. If StealthCoder is running during the live OA, it's your hedge if the pointer update slips your mind under pressure.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

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 for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as longest substring without repeating characters. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Wex's OA.

Wex reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Longest Substring Without Repeating Characters FAQ

What's the trick to Longest Substring Without Repeating Characters?+

Use a sliding window with a map of each character's last seen index. When you hit a repeat inside the window, move the left edge to just past the previous occurrence. One pass, O(n) time. That's the whole idea.

What's the most common bug on this problem?+

Letting left move backward. If a character's last index is before the current left, you must ignore it. Use left = max(left, last[c] + 1). Skipping that max gives wrong answers on strings like abba.

How hard is this really for the Wex OA?+

It's a standard medium, and it was reported for Wex in September 2026. The pattern is well known, so the difficulty is clean execution, not discovery. Edge cases are the empty string, a single character, and all identical characters.

Do I need dynamic programming here?+

No. You can frame it as DP on the best window ending at each index, but the sliding window is simpler and faster. Track the window start and the last seen positions. You don't need a table.

How do I prepare in 48 hours?+

Write the sliding window from memory twice, once with a hash map and once with a 128-slot array. Trace abcabcbb, bbbbb, and pwwkew by hand. Then test the empty string and abba. That covers nearly every failure mode.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Wex.

OA at Wex?
Invisible during screen share
Get it