Count Substrings with Exactly k Distinct Characters in a String
Aug 26, 2024 · 4 min read · Problem Statement Given a string of lowercase alphabets, count all possible substrings (not necessarily distinct) that have exactly k distinct characters. Example:Input: S = "aba", K = 2Output: 3Explanation: The substrings are "ab", "ba", and "aba". ...
Join discussion