FastPrepLongest Substring Without Repeating Characters
Problems/Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

Netflix logoNetflix● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Netflix phone screen for a full-time role. The report leaves out the rule for empty input, the allowed characters, and limits on input size and resources. We filled those in.

Our version is about 98% the same as the reported question.

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) → int

Examples

Example 1

s = "abcabcbb"return = 3

The substring abc has three distinct characters. Any longer substring repeats at least one character.

Example 2

s = "pwwkew"return = 3

Both wke and kew have length 3. The answer concerns a contiguous substring, not a subsequence.

Example 3

s = ""return = 0

The empty string contains no non-empty substring, so its longest valid length is 0.

Constraints

  • 0 <= s.length <= 100000
  • s contains 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

Netflix interview experiences

  • Netflix interviews · 2026
All Netflix interview questionsSee Netflix hiring insights
Saved
class Solution {
    public int lengthOfLongestSubstring(String s) {
      // write your code here
    }
}
Checking account…