Substrings with k distinct characters
Your task
Given a string s of lowercase letters and an integer k (1 <= k <= 26, 1 <= len(s) <= 10^4), return the number of (contiguous) substrings that contain EXACTLY k distinct characters.
Examples
count_substrings_with_k_distinct(s: str, k: int) -> intExample 1
Input
count_substrings_with_k_distinct("pqpqs", 2)Output
7