#K14701. Longest Substring with At Most Two Distinct Characters
Longest Substring with At Most Two Distinct Characters
Longest Substring with At Most Two Distinct Characters
Given a string s
, your task is to find the length of the longest substring that contains at most two distinct characters. A substring is a contiguous portion of the string.
For example, given s = "eceba"
, the longest substring that contains at most two distinct characters is "ece"
, which has a length of 3.
It is guaranteed that s
consists of only English letters.
inputFormat
The input consists of a single line containing the string s
.
outputFormat
Output a single integer representing the length of the longest substring of s
that contains at most two distinct characters.
abcbbbbcccbdddadacb
10