ByteMonk logo
All problems

medium · 408 tests

Longest Substring Without Repeating Characters

Given a string s of lowercase letters, digits and spaces, print the length of the longest substring that contains no repeated character. Spaces count as characters.

Input

Line 1: t, the number of cases (1 <= t <= 1000).

Then t lines, one string s per line (1 <= |s| <= 2 * 10^5). The total length over one input is at most 10^6.

Output

For each case, one line: one integer.

Note

Read each case as a whole line; do not split on spaces. An O(n^2) solution will time out on the larger tests.

Samples

Input 1

1
abcabcbb

Output 1

3

Input 2

1
pwwkew

Output 2

3

Input 3

1
bbbbb

Output 3

1

Input 4

1
ab ba c

Output 4

4

Scoring

  1. Basic correctness20 pts
  2. Edge cases15 pts
  3. Random small20 pts
  4. Random large15 pts
  5. Adversarial10 pts
  6. Performance20 pts
2s · 256 MB
Longest Substring Without Repeating Characters · Coding · ByteMonk