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

Longest Substring Without Repeating Characters

Highspot logoHighspot● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand report from a Highspot senior software engineer links straight to the well-known Longest Substring Without Repeating Characters problem. It was asked in an onsite interview. Our version is about 99% the same as the reported question.

Given a string s, return the length of its longest contiguous substring that contains no repeated characters.

Function

lengthOfLongestSubstring(s: String) → int

Examples

Example 1

s = "abcabcbb"return = 3

"abc" is a longest substring without repeated characters, so the answer is 3.

Example 2

s = "bbbbb"return = 1

Every substring with distinct characters contains at most one b.

Constraints

  • 1 <= s.length <= 10^5.
  • s contains English letters, digits, and common symbols.

More Highspot Onsite Interview questions

  • Minimum Window SubstringONSITE INTERVIEW · Seen Aug 2024
  • Number of IslandsONSITE INTERVIEW · Seen Aug 2024

Similar questions at other companies

  • Longest Substring Without Repeating CharactersOracle · ONSITE INTERVIEWOracle interview questions
  • Longest Substring Without Repeating CharactersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Longest Substring Without Repeating CharactersMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Longest Substring Without Repeating CharactersGoogle · ONSITE INTERVIEWGoogle interview questions
  • Longest Substring Without Repeating CharactersAmazon · ONSITE INTERVIEW
  • Longest Substring Without Repeating CharactersInfosys · ONSITE INTERVIEWInfosys interview questions
  • Longest Substring Without Repeating CharactersOmnissa · ONSITE INTERVIEWOmnissa interview questions
  • Longest Substring Without Repeating CharactersBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Longest Substring with At Most K Distinct CharactersGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Longest Substring Without Repeating CharactersBank of America · ONSITE INTERVIEWBank of America interview questions
See Highspot hiring insights
Saved
class Solution {
    public int lengthOfLongestSubstring(String s) {
        // Write your code here.
    }
}
Checking account…