Longest Substring with At Most K Distinct Characters

This is a problem asked by Google. Given a string, find the longest substring that contains only two unique characters. For example, given “abcbbbbcccbdddadacb”, the longest substring that contains 2 unique character is “bcbbbbcccb”. 1. Longest Substring Which Contains 2 Unique Characters In this solution, a hashmap is used to track the unique elements in … Read more