Problem · Sliding Window
Longest Substring Without Repeating Characters
Learn this problemProblem statement
A quick note: this problem is backed by a real Omnissa onsite interview report that directly named Longest Substring Without Repeating Characters. The report did not include an exact function interface, examples, constraints, or character-set rules. The core task match is about 95%.
Given a string s, return the length of the longest substring that contains no repeated characters.
Interview Follow-up
This was part of a rapid-fire three-problem round in which the candidate presented brute-force, improved, and optimal approaches and wrote working code for each problem.
Function
lengthOfLongestSubstring(s: String) → intExamples
Example 1
s = "abcabcbb"return = 3The longest substrings without repeated characters include "abc", with length 3.
Example 2
s = "bbbbb"return = 1Every valid substring without repeats has length 1.