Coding

Longest Substring with Two Distinct Characters

Find the longest substring with at most two distinct characters.

Input: s = "ccaabbb"

Output: 5

Explanation: The substring "aabbb" contains exactly two distinct characters and has a maximum length of 5.

Was asked at

Practice this question with AI

First session is free - no credit card required.

Go Premium

More interviews, more skills, more success.

No answers yet

Be the first to share your approach to this question

Practice More Questions