Skip to content
QuantReadySign In
#049easyStrings

Longest Unique Ticker Stream

Time Limit: 2sMemory: 256MB

Problem

A trading firm receives a continuous stream of single-character market signals. Each character represents a different signal type. An analyst wants to find the longest contiguous segment of the stream where every signal is distinct (no signal type repeats within the segment).

Given the signal stream as a string s, return the length of the longest contiguous substring that contains no repeating characters.

Input Format

  • A single line containing the string s.

Output Format

A single integer: the length of the longest substring with all unique characters.

Examples

Example 1
Input(A single line containing the string s.)
AAPLGMSFT
Output
8

The longest substring without repeating characters is 'APLGMSFT' (length 8).

Example 2
Input(A single line containing the string s.)
AAAA
Output
1

Every character is the same, so the longest unique substring is just 'A' (length 1).

Constraints

  • 0 <= len(s) <= 50000
  • s consists of uppercase English letters
Loading interactive editor…