#C1942. Longest Unique Substring
Longest Unique Substring
Longest Unique Substring
Given a string s
, find the length of the longest substring without repeating characters.
The problem can be formulated as follows:
Find the maximum value of \( j - i + 1 \) such that all characters in the substring \( s[i \ldots j] \) are distinct.
For example:
- If
s = "abcabcbb"
, the answer is3
(the substring "abc"). - If
s = "bbbbb"
, the answer is1
(the substring "b"). - If
s = "pwwkew"
, the answer is3
(the substring "wke").
Please note that the input is provided via stdin and the answer must be printed to stdout.
inputFormat
The input consists of a single line containing the string s
. The string may be empty and will consist of printable ASCII characters.
outputFormat
Output a single integer which is the length of the longest substring of s
that has no repeating characters.
abcabcbb
3