#K58302. Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Given a string s, your task is to determine the length of the longest contiguous substring that does not contain any repeating characters.
To solve this problem, you can use a sliding window technique. Each time you encounter a repeated character, adjust the window's starting index accordingly. Mathematically, if a character is repeated, update the start index as follows: $$start = last\_index[char] + 1$$, and compute the current window length with $$i - start + 1$$.
For example, when s = "abcabcbb"
, the longest substring without repeating characters is "abc" with a length of 3.
inputFormat
The input consists of a single line string s read from standard input (stdin).
outputFormat
Output a single integer to standard output (stdout) representing the length of the longest contiguous substring of s that contains no repeating characters.
## sampleabcabcbb
3