Tap here to switch tabs
Problem
Submissions

Problem: Longest Substring with At Most Two Distinct Characters

Longest Substring with At Most Two Distinct Characters asks you to find the length of the longest contiguous part of a string containing no more than two different characters.

Statement

Given a string s, return the length of the longest substring that contains at most 22 distinct characters.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s consists of English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Substring with At Most Two Distinct Characters

Longest Substring with At Most Two Distinct Characters asks you to find the length of the longest contiguous part of a string containing no more than two different characters.

Statement

Given a string s, return the length of the longest substring that contains at most 22 distinct characters.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s consists of English letters.