#K62837. Longest Substring Without Repeating Characters

    ID: 31620 Type: Default 1000ms 256MiB

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 without any repeating characters.

This problem can be formally defined as follows: Given a string \( s \), find \( \max_{0 \leq i \leq j < |s|} (j-i+1) \) such that every character in \( s[i\ldots j] \) is unique.

For example:

  • For s = "abcabcbb", the longest substring without repeating characters is "abc" with length 3.
  • For s = "bbbbb", the longest substring is "b" with length 1.
  • For s = "pwwkew", one of the longest substrings is "wke" with length 3.

This problem tests your understanding of efficient string traversal techniques, such as the sliding window approach.

inputFormat

The input consists of a single line containing a string s. The string may include letters, digits, spaces and special characters.

Note: Input is read from standard input (stdin).

outputFormat

Output a single integer representing the length of the longest substring of s without repeating characters. The result is printed to standard output (stdout).

## sample
abcabcbb
3