#K71717. Longest Unique Substring
Longest Unique Substring
Longest Unique Substring
Given a string \(s\), find the length of the longest substring that contains only unique characters. In other words, you are to determine the maximum value of \(j - i + 1\) such that the substring \(s[i \ldots j]\) does not contain any duplicate characters.
This problem can be solved efficiently using the sliding window technique. The key is to maintain a window with unique characters and update the window whenever a repeated character is encountered. The update formula for the current window length is \(\text{current length} = end - start + 1\), where start and end mark the boundaries of the current substring.
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 representing the length of the longest substring of \(s\) that contains only unique characters.
## sampleabcabcbb
3