Practice arena
C++17·2 s·128 MB
LinearIntermediate
Longest unique window
For each string, return the length of its longest contiguous substring containing no repeated character.
Input
- — The first line contains T.
- — Each of the next T lines contains one non-empty ASCII string without spaces.
Output
Print one maximum length per line.
Technique
sliding window + last position
Target
O(n) expected
Constraints & sample
- 1 ≤ |s| ≤ 100,000
- The sum of all string lengths is at most 200,000
Sample input
4 abcabcbb bbbbb pwwkew dvdf
Expected output
3 1 3 3
Before you submit
- Test the smallest valid input and one awkward edge case.
- Keep the solution within O(n) expected.
- Match spacing and line breaks exactly before checking 8 hidden cases.
Draft saved locally · 362 / 30,000
Ln 1, Col 1Spaces: 4UTF-8LFC++17
Visible testcases
Editable and stored only in this browser. Hidden judge cases never change.
Checking your session…
Run checks Sample · Submit checks 8 hidden cases
Run the sample first, then send your solution through 8 hidden cases.
Code runs in an isolated Judge0 environment. Drafts and custom visible cases stay on this device; submission metadata and progress sync to MongoDB.