#C12994. Longest Substring Without Repeating Characters

    ID: 42482 Type: Default 1000ms 256MiB

Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

Given a string s, find the length of the longest substring that contains no repeated characters. The substring is a contiguous segment of characters, and each character within must be unique. Your solution should be efficient and achieve an optimal time complexity of \(O(n)\). This problem is a classic challenge in coding interviews and competitive programming.

For example, if s = "abcabcbb", the longest substring without repeating characters is "abc", which has a length of 3.

inputFormat

The input consists of a single line containing the string \(s\). The string can be empty or have a length up to \(10^5\) characters. All characters are among the 128 ASCII characters.

outputFormat

Output a single integer representing the length of the longest substring of \(s\) that contains no duplicate characters.

## sample
abcabcbb
3