Longest Substring Without Repeating Characters
Updated
Problem statement
Given a string s, return the length of the longest contiguous substring whose characters are all distinct.
For this exercise, assume s contains printable ASCII characters. The empty string has answer 0.
Function
lengthOfLongestSubstring(s: String) → intExamples
Example 1
s = "abcabcbb"return = 3The substring abc has three distinct characters. Any longer substring repeats at least one character.
Example 2
s = "pwwkew"return = 3Both wke and kew have length 3. The answer concerns a contiguous substring, not a subsequence.
Example 3
s = ""return = 0The empty string contains no non-empty substring, so its longest valid length is 0.
Constraints
0 <= s.length <= 100000scontains printable ASCII characters.
More Netflix interview questions
- Timed Cache with Sidecar CleanupPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Repeated Titles in Viewing HistoryPHONE SCREEN · Seen Sep 2026
- Capacity-Limited Timed CachePHONE SCREEN · Seen Sep 2026
- Custom Record and Free-Form Field ParserPHONE SCREEN · Seen Sep 2026
- Dynamic Broadcast TimesPHONE SCREEN · Seen Aug 2026
- Count String Pairs With Disjoint CharactersPHONE SCREEN · Seen Aug 2026
- Deduplicate Homepage Content Across RowsPHONE SCREEN · Seen Aug 2026
- Longest Consecutive Identical Character RunPHONE SCREEN · Seen Aug 2026
- Topological Sort for Ads TasksPHONE SCREEN · Seen Jun 2026
- Score-Rotating Movie PlaylistONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Longest Substring Without Repeating CharactersAngel One · PHONE SCREEN
- Longest Substring Without Repeating CharactersNykaa · PHONE SCREENNykaa interview questions
- Longest Substring Without Repeating CharactersIBM · PHONE SCREENIBM interview questions
- Longest Substring Without Repeating CharactersTikTok · PHONE SCREENTikTok interview questions
- Find Word-Multiset WindowsAmazon · PHONE SCREEN
- Find the First Contiguous HaikuFaire · PHONE SCREEN
- Longest Substring Without Repeating CharactersCapgemini · PHONE SCREENCapgemini interview questions
- Longest Substring Without Repeating CharactersWex · PHONE SCREEN
- Minimum Window of Required WordsSalesforce · PHONE SCREENSalesforce interview questions
- Longest Substring Without Repeating CharactersRedNote · PHONE SCREEN