#C6645. Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Given a string s, your task is to find the length of the longest substring that does not contain any repeating characters.
The problem can be formulated mathematically as follows: If S is the input string and S[i...j] is a substring of S with all distinct characters, then you need to compute \[ \max_{0 \le i \le j < n} \{j - i + 1 \mid S[i...j] \text{ has all unique characters}\} \] where \( n \) is the length of the string.
For example, for the input abcabcbb
, the longest substring without repeating characters is abc
with a length of 3.
inputFormat
The input is provided via standard input (stdin) as a single line containing the string s. The string s may consist of letters, digits, spaces, and special characters. Note that if the input represents an empty string, it should be interpreted accordingly.
outputFormat
Output the integer representing the length of the longest substring which contains no repeating characters. The output is printed to standard output (stdout).
## sampleabcabcbb
3