#K80392. Longest Substring Without Repeating Characters

    ID: 35520 Type: Default 1000ms 256MiB

Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

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

Example:

  • Input: "abcabcbb", Output: 3
  • Input: "bbbbb", Output: 1

The problem can be solved efficiently using the sliding window technique. In particular, you can maintain a window with two pointers and use a hash map (or an array of fixed size, if applicable) to store the last occurrence of each character.

Note: The input is provided through standard input (stdin) and the output should be printed to standard output (stdout).

inputFormat

The input consists of a single line containing a string s, which may include spaces and other characters.

Read the input from standard input (stdin).

outputFormat

Output a single integer representing the length of the longest substring without repeating characters.

Write your output to standard output (stdout).

## sample
abcabcbb
3