Coding Round 1
Senior
programming
**Longest Substring with At Most Two Distinct Characters**\nGiven a string s, return the length of the longest substring that contains at most two distinct characters. This problem will test your understanding of the sliding window technique.\n\n**Function Signature**: `def length_of_longest_substring_two_distinct(s: str) -> int:`\n\n**Example 1**: \n**Input:** s = "eceba" \n**Output:** 3 \n**Explanation:** The longest substring is "ece" with length 3.\n\n**Example 2**: \n**Input:** s = "ccaabbb" \n**Output:** 5 \n**Explanation:** The longest substring is "aabbb" with length 5.\n\n**Constraints:** \n- 1 <= s.length <= 10^5 \n- s consists of English letters.
Suggested Answer