#C11039. Longest Substring Without Repeating Characters

    ID: 40311 Type: Default 1000ms 256MiB

Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

Given a string \(s\) consisting of Latin letters and digits, find the length of the longest substring that contains no repeating characters. A substring is a contiguous sequence of characters within the string. The goal is to determine the maximum length \(L\) such that there exists a substring of \(s\) where all characters are unique.

Example: For the string "abcabcbb", the longest substring without repeating characters is "abc" with length 3.

The problem can be approached using a sliding window technique where you maintain two pointers and a record of the last seen index for each character. The formula for updating the window length is:

[ L = \max_{0 \leq i \leq j < n} (j - i + 1) \quad \text{subject to substring } s[i\ldots j] \text{ having all distinct characters.} ]

inputFormat

The input is provided via standard input (stdin). It consists of a single line containing the string \(s\). The string \(s\) will only contain Latin letters and digits, and its length is at least 1.

outputFormat

The output, sent to standard output (stdout), should be a single integer representing the length of the longest substring of \(s\) that does not contain any repeating characters.

## sample
abcabcbb
3