#K5836. 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 repeated characters. This problem requires you to implement an efficient algorithm (typically using a sliding window approach) to determine the maximum length among all substrings of s with all distinct characters.
For instance, for the input abcabcbb
, the longest substring without repeating characters is abc
which has a length of 3.
You will be given multiple test cases. Read the input from stdin and output the result for each test case on a new line to stdout.
inputFormat
The first line of input contains an integer T representing the number of test cases. Each of the following T lines contains a string s.
outputFormat
For each test case, output a single line with an integer representing the length of the longest substring of s which does not have any repeating characters.
## sample3
abcabcbb
bbbbb
pwwkew
3
1
3
</p>