#C3503. Longest Unique Substring

    ID: 46938 Type: Default 1000ms 256MiB

Longest Unique Substring

Longest Unique Substring

You are given a string s and your task is to determine the length of the longest substring that contains no repeated characters. In other words, you need to find the maximum length L such that every character in the substring is unique.

Formally, let the input string be denoted by s and a substring s[i..j] (where \(0 \le i \le j < n\)) is said to have unique characters if every character in that substring appears only once. The goal is to compute the maximum value of \(L = j - i + 1\) over all substrings with unique characters.

Example:

  • Input: "abcabcbb"
  • Output: 3 (the substring "abc" is the longest that contains all unique characters)

inputFormat

The input consists of a single line containing a string s. The string may include spaces and other printable characters. It is read from standard input.

outputFormat

Output a single integer representing the length of the longest substring of s without any repeating characters. The result should be printed to standard output.

## sample
abcabcbb
3