#K80472. Longest Substring Without Repeating Characters

    ID: 35538 Type: Default 1000ms 256MiB

Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

Given a string s consisting of lowercase English letters, your task is to find the length of the longest substring without any repeating characters. A substring is a contiguous sequence of characters within a string.

For example, given s = abcabcbb, the longest substring without repeating characters is abc, with length 3. Similarly, if s = bbbbb, the answer is 1.

The problem can be mathematically described as finding the maximum value of
\(\text{max}(j - i + 1)\) for all indices \(i, j\) such that all characters in \(s[i \ldots j]\) are distinct.

This is a classic problem that can be efficiently solved using the sliding window technique.

inputFormat

The input begins with an integer T, representing the number of test cases. Each of the following T lines contains a string made up of lowercase English letters.

outputFormat

For each test case, output a single line containing an integer that represents the length of the longest substring without repeating characters.## sample

3
abcabcbb
pwwkew
bbbbb
3

3 1

</p>