#C12740. Longest Non-Repeating Substring
Longest Non-Repeating Substring
Longest Non-Repeating Substring
You are given a string s. Your task is to find the length of the longest substring without repeating characters.
For example, given the string "abcabcbb", the answer is 3, as the longest substring without repeating characters is "abc".
This problem can be solved using the sliding window technique combined with a hash table. Let \( s \) be the input string of length \( n \). Consider a window with two pointers, and use a hash map to store the last seen index of each character. When a repeating character is encountered, move the start pointer to the right of the previous occurrence.
The algorithm runs in \( O(n) \) time complexity.
inputFormat
The input consists of a single line containing a non-empty string s. The string can include spaces and other printable characters.
Note: In some test cases, the string might be empty.
outputFormat
Output a single integer representing the length of the longest substring of s that does not contain any repeating characters.
## sampleabcabcbb
3