#C13935. Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Given a string s
, determine the length of the longest contiguous substring that does not contain any repeating characters. You are not allowed to use any additional data structures (such as arrays, sets, or hashmaps) to store the characters of the substring.
The goal is to implement an algorithm that, for every possible contiguous substring, computes the maximum length of a substring where every character appears only once. For instance, if s = \texttt{abcabcbb}
, the answer is 3
corresponding to the substring "abc". Similarly, if s = \texttt{pwwkew}
, the answer would also be 3
.
Note: The constraint prohibits using extra data structures to keep track of characters. Employing a two-pointer or sliding window technique with simple loops is recommended.
inputFormat
The input consists of a single line containing the string s
. The string may include spaces, digits, symbols, and can be empty.
outputFormat
Output a single integer which is the length of the longest substring without any repeating characters.
## sampleabcabcbb
3