#C5603. 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 substring of s
that contains only unique characters.
A substring is a contiguous sequence of characters within a string. In this problem, no character should appear more than once in the considered substring.
The problem can be formulated mathematically as follows:
Find the maximum k such that there exists an index i for which the substring s[i:i+k]
has all distinct characters. That is, for any two indices j and l with i ≤ j < l < i+k, we have s[j] ≠ s[l]
.
inputFormat
The input consists of a single line containing the string s
. The string may be empty.
Input is provided via standard input (stdin).
outputFormat
Output the length of the longest substring of s
that contains only unique characters.
Output the result to standard output (stdout).
## sampleabcabcbb
3