#C5994. Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Given a string s
, your task is to compute the length of the longest substring that contains no repeated characters. A substring is a contiguous sequence of characters from s
.
For example, if s = "abcabcbb"
, the answer is 3, because the longest substring without repeating characters is "abc"
.
You may use a sliding window approach or any other optimal method. The problem can be formalized as follows:
$$ L = \max_{0 \leq i < n} \{ \text{length of the substring starting at index } i \text{ with all distinct characters} \}.$$
Your solution must read input from standard input (stdin) and output the result to standard output (stdout).
inputFormat
The input consists of a single line containing the string s
. The string might be empty or contain any characters including letters, digits, and special symbols.
outputFormat
Output a single integer representing the length of the longest substring of s
that contains no repeating characters.
abcabcbb
3