#C3186. Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Given a string S
, find the length of the longest substring that does not contain any repeating characters.
You are required to implement a solution using a sliding window technique. More formally, if you maintain two pointers l (left) and r (right), the length of the current substring is given by \( r - l + 1 \). Your task is to compute the maximum value of this quantity over all substrings of S
that do not contain duplicate characters.
Example:
- For
S = "abcabcbb"
, the answer is 3 because the longest substring without repeating characters is "abc". - For
S = "bbbbb"
, the answer is 1 because the longest substring without repeating characters is "b". - For
S = "pwwkew"
, the answer is 3 because the longest substring without repeating characters is "wke".
inputFormat
The input consists of a single line containing the string S
(which may be empty) composed of ASCII characters.
outputFormat
Output a single integer which is the length of the longest substring of S
that does not contain repeating characters.
abcabcbb
3