#K92112. Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Given a string s
, find the length of the longest substring that contains no repeating characters.
The problem is to determine the maximum number of characters in any contiguous segment of the string such that all characters in that segment are unique. This is a typical sliding window problem that can be solved in linear time using two pointers.
For example, for the input "abcabcbb"
, the longest substring without repeating characters is "abc"
with a length of 3.
Note: If the input string is empty, the answer is 0.
inputFormat
The input is a single line containing the string s
. The string may be empty and can contain any visible ASCII characters.
Input is provided via stdin.
outputFormat
Output a single integer, which is the length of the longest substring of s
with all distinct characters.
Output is printed to stdout.
## sampleabcabcbb
3