#C8172. Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Given a string s, determine the length of the longest substring that contains no repeated characters. This problem can be solved using the sliding window technique where you track the last seen positions of characters.
The mathematical formulation can be expressed as finding the maximum k such that there exists a substring s[i...j] with no duplicate characters, where k = j - i + 1.
For example:
- Input:
abcabcbb
→ Output:3
- Input:
bbbbb
→ Output:1
- Input:
pwwkew
→ Output:3
inputFormat
The input consists of a single line containing a string s
composed of English letters and possible symbols. The string may be empty.
outputFormat
Output an integer representing the length of the longest substring of s
that does not contain any repeating characters.
abcabcbb
3