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

Longest Substring Without Repeating Characters

RedNote logoRedNote● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a RedNote phone screen. Our version is about 99% the same as the reported question.

Given a string text, return the length of its longest contiguous substring whose characters are all distinct.

The empty string has answer 0.

Function

lengthOfLongestSubstring(text: String) → int

Examples

Example 1

text = "abcabcbb"return = 3

abc is a longest substring with no repeated character.

Example 2

text = "pwwkew"return = 3

wke has length three. The answer concerns a contiguous substring, not a subsequence.

Constraints

  • 0 <= text.length() <= 100000
  • text contains only printable ASCII characters.

More RedNote Phone Screen questions

  • Timer Job Scheduler Wake-upsPHONE SCREEN · Seen Nov 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 CharactersNetflix · PHONE SCREENNetflix interview questions
See RedNote hiring insights
Saved
class Solution {
    public int lengthOfLongestSubstring(String text) {
        // Write your code here.
    }
}
Checking account…