Longest Substring Without Repeating Characters
Updated
Problem statement
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) → intExamples
Example 1
s = "abcabcbb"return = 3A longest substring is abc, of length 3.
Example 2
s = "bbbbb"return = 1Every substring of length greater than one repeats b.
Constraints
0 <= s.length <= 50000.- Every character is printable ASCII, with character code
32through126.
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