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

Longest Substring Without Repeating Characters

Expedia logoExpedia● MediumNEW GRADINTERNOAONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Printable ASCII, exact character comparison and empty-input behavior are practice assumptions. The longest-distinct-substring task matches the source at about 98%.

Return the length of the longest contiguous substring of s that has no repeated character.

Compare characters exactly: uppercase and lowercase letters differ, and spaces count as characters. The empty string has answer zero.

Function

lengthOfLongestSubstring(s: String) → int

Examples

Example 1

s = "abcabcbb"return = 3

A longest substring is abc, of length 3.

Example 2

s = "bbbbb"return = 1

Every substring of length greater than one repeats b.

Constraints

  • 0 <= s.length <= 50000.
  • Every character is printable ASCII, with character code 32 through 126.

More Expedia Onsite Interview questions

  • Scramble StringONSITE INTERVIEW · Seen Sep 2026
  • Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
  • Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
  • Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
  • Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
  • Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
  • Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
  • Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
  • Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
  • Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024

Similar questions at other companies

  • Longest Substring Without Repeating CharactersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Longest Substring Without Repeating CharactersMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Shortest Deletion for Distinct CharactersOracle · ONSITE INTERVIEWOracle interview questions
  • Longest Substring Without Repeating CharactersGoogle · ONSITE INTERVIEWGoogle interview questions
  • Perfect SubstringAXQ Capital · OA
  • Longest Distinct StringSuperhuman · OASuperhuman interview questions
  • Longest Substring Without Repeating CharactersAmazon · ONSITE INTERVIEW
  • Longest Substring Without Repeating CharactersAkuna Capital · OAAkuna Capital interview questions
  • Longest Substring Without Repeating CharactersInfosys · ONSITE INTERVIEWInfosys interview questions
  • Perfect SubstringsVisa · OAVisa interview questions

Interview reports that mention this question

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia New Grad SDE Interviews: 20 Experiences (Part 1 of 3)

Expedia interview experiences

  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public int lengthOfLongestSubstring(String s) {
        // Write your code here.
    }
}
Checking account…