#K75562. 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 no repeating characters. A substring is a contiguous sequence of characters within the string.
One efficient way to solve this problem is by using a sliding window technique with a time complexity of \(O(n)\), where \(n\) is the length of the string. Formally, if a valid substring \(S[l\dots r]\) is defined by the indices \(l\) and \(r\) (where \(0 \le l \le r < n\)) with all unique characters, then the goal is to compute:
$$\max_{0 \le l \le r < n} (r-l+1)$$
subject to the condition that every character in \(S[l\dots r]\) is distinct.
inputFormat
The first line contains a single integer \(T\) representing the number of test cases. Each of the following \(T\) lines contains a string \(S\) (which may be empty).
outputFormat
For each test case, output a single integer representing the length of the longest substring of \(S\) that contains no repeating characters. Each result should be printed on its own line.
## sample1
abcabcbb
3
</p>