#K1291. 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 contains all unique characters. This is a classical sliding window problem in which you need to determine the maximum length L such that, for some indices \(i\) and \(j\) with \(0 \le i \le j < n\), the substring \(s[i \ldots j]\) has no repeated characters. For example, if \(s = \texttt{abcabcbb}\), the longest substring is \(\texttt{abc}\) with length 3.
The problem can be formally described as: Given a string \(s\) of length \(n\), find \[ L = \max_{0 \le i \le j < n} \{ j - i + 1 \mid s[i \ldots j] \text{ contains all unique characters} \}. \]
Input and output are handled via standard input and standard output respectively.
inputFormat
The input consists of a single line containing the string s. The string may include spaces and other printable characters.
outputFormat
Output a single integer — the length of the longest substring of s that contains all unique characters.
## sampleabcabcbb
3