#C13458. 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 of s
that contains no repeating characters.
In other words, let \( s = s_1s_2\ldots s_n \). You are required to calculate the value of
\( \max_{1 \leq i \leq n} \{ j-i+1 \} \)
subject to the condition that the substring \( s_i s_{i+1} \ldots s_j \) contains only unique characters. For example, for the input "abcabcbb"
, the longest substring with all unique characters is "abc"
with length 3.
This is a typical problem that can be solved efficiently using a sliding window approach.
inputFormat
A single string is provided via standard input (stdin). The string may be empty and can contain spaces or any printable characters.
outputFormat
Output a single integer to standard output (stdout) representing the length of the longest substring with all unique characters.## sample
abcabcbb
3