README ¶ < Previous Next > 159. Longest Substring with At Most Two Distinct Characters (Medium) Given a string s , find the length of the longest substring t that contains at most 2 distinct characters. Example 1: Input: "eceba" Output: 3 Explanation: t is "ece" which its length is 3. Example 2: Input: "ccaabbb" Output: 5 Explanation: t is "aabbb" which its length is 5. Related Topics [Hash Table] [Two Pointers] [String] [Sliding Window] Similar Questions Longest Substring Without Repeating Characters (Medium) Sliding Window Maximum (Hard) Longest Substring with At Most K Distinct Characters (Hard) Subarrays with K Different Integers (Hard) Expand ▾ Collapse ▴ Documentation ¶ There is no documentation for this package. Source Files ¶ View all Source files longest_substring_with_at_most_two_distinct_characters.go Click to show internal directories. Click to hide internal directories.