#C5463. Longest Substring Without Repeating Characters

    ID: 49115 Type: Default 1000ms 256MiB

Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

You are given an integer T representing the number of test cases. For each test case, you are provided with a string S. Your task is to find the length of the longest substring of S that contains no repeated characters.

For example, given the string abcabcbb, the longest substring without repeating characters is abc with a length of 3.

In mathematical terms, if we denote the function as \( f(s) \) which returns the length of the longest substring with all distinct characters, then for a test case with string \( s \), you are to compute \( f(s) \).

inputFormat

The input is read from standard input (stdin). The first line contains an integer T, the number of test cases. Each of the following T lines contains a string S.

outputFormat

For each test case, output the length of the longest substring without repeating characters on a new line to standard output (stdout).## sample

5
abcabcbb
bbbbb
pwwkew

a
3

1 3 0 1

</p>