#C10943. Longest Substring Without Repeating Characters

    ID: 40204 Type: Default 1000ms 256MiB

Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

You are given a string, and your task is to determine the length of the longest substring that contains no repeated characters. A substring is a contiguous sequence of characters within the string. The challenge is to efficiently determine the maximum length of such a substring.

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

The problem can be mathematically formulated as: Given a string \( s \), find the maximum \( L \) such that there exists a substring \( s[i \ldots j] \) with \( j - i + 1 = L \) and all characters in \( s[i \ldots j] \) are unique.

inputFormat

The first line contains an integer \( t \) representing the number of test cases. Each of the following \( t \) lines contains a single string.

outputFormat

For each test case, output one line containing a single integer which is the length of the longest substring with all unique characters.

## sample
3
abcabcbb
bbbbb
pwwkew
3

1 3

</p>