#K51057. Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Given a string s
, your task is to find the length of the longest substring that contains no repeating characters.
For a string s
with length n
, we define the length of a substring starting at index i
and ending at index j-1
(for 0 ≤ i < j ≤ n
) as j - i
. We require that all characters in s[i...j-1]
are unique. In mathematical notation, the answer is given by:
[ L = \max_{0 \leq i \leq j \leq n ; \text{and} ; s[i...j-1], \text{has all unique characters}} (j - i) ]
You need to implement an efficient solution that works well for large inputs.
inputFormat
The input consists of a single line containing a string s
. The string may be empty and may contain any visible characters.
outputFormat
Output a single integer, which is the length of the longest substring of s
that does not contain any repeating characters.
abcabcbb
3