#C12949. Longest Unique Substring

    ID: 42432 Type: Default 1000ms 256MiB

Longest Unique Substring

Longest Unique Substring

You are given a string s. Your task is to find the length of the longest substring of s that does not contain any repeating characters.

The solution should implement an efficient algorithm, preferably using a sliding window technique. The time complexity should ideally be O(n), where n is the length of the input string.

For example:

  • For the input abrkaabcdefghijjxxx, the longest substring is abcdefghij with a length of 10.
  • For the input aaaaaa, every character is the same so the answer is 1.
  • For an empty string, the answer should be 0.

Note: All formulas in this problem, if any, must be in LaTeX format.

inputFormat

The input is provided via stdin as a single line containing the string s. The string may contain spaces and other printable characters.

Example:

abrkaabcdefghijjxxx

outputFormat

The output should be printed to stdout as a single integer representing the length of the longest substring without any repeating characters.

Example:

10
## sample
abrkaabcdefghijjxxx
10