Example with repeats
Input
s = "abac", k = 2
Output
[2, 2, 2]
Windows: 'ab' -> 2, 'ba' -> 2, 'ac' -> 2 distinct characters each.
Full lesson preview
For each substring (window) of length K, count how many distinct characters it contains.
Problem statement
Task
Examples
Input
s = "abac", k = 2
Output
[2, 2, 2]
Windows: 'ab' -> 2, 'ba' -> 2, 'ac' -> 2 distinct characters each.
Input format
Output format
Constraints
Samples
Input
s = "aaaa", k = 2
Output
[1, 1, 1]
Each window 'aa' has only one distinct character.