#C12854. Longest Unique Substring
Longest Unique Substring
Longest Unique Substring
You are given a string s. Your task is to find the length of the longest substring without repeating characters.
For example, given s = "abcabcbb"
, the longest substring without repeating characters is "abc"
, which has a length of 3.
This problem requires you to carefully track the last seen index of characters in order to update a sliding window over the string. Formally, if you denote the substring by indices \(i\) to \(j\), then all characters in \(s[i], s[i+1], \ldots, s[j]\) must be unique.
inputFormat
The input consists of a single line containing the string s. The string can contain letters, digits, and other symbols. Its length is \(n\) where \(0 \leq n \leq 10^5\).
outputFormat
Output a single integer, which is the length of the longest substring of s that contains no repeating characters.
## sampleabcabcbb
3