Longest Contiguous Substring in Which No Character Repeats
Company: ByteDance
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Overview: A string problem that asks for the length of the longest contiguous substring in which no character repeats. It tests telling substrings apart from subsequences, exact case-sensitive character handling, and an efficient pass over strings of up to 100,000 printable characters.
Read the full ByteDance Software Engineer interview experience this question came from
Constraints
- 0 <= len(s) <= 100000
- Every character of s is printable ASCII (codes 32 through 126).
Examples
Input: ('',)
Expected Output: 0
Explanation: The empty string has answer 0.
Input: ('a',)
Expected Output: 1
Explanation: A single character is a valid substring of length 1.
Hints
- Only contiguous runs of s count; a selection of characters that skips a position is not a substring.
- Compare characters exactly: an upper-case letter and its lower-case form differ, and spaces and punctuation marks are characters too.
- There are only 95 printable ASCII characters, so no qualifying substring can be longer than 95.