res
to 0 to store the result (number of equal count substrings).s
and store it in max_unique
.unique
from 1 to max_unique
.unique
, calculate the window size len
as count * unique
.cnt
to store the count of each character within the window.has_count
to 0 to store the number of characters that have exactly count
occurrences in the window.s
.cnt
and update has_count
accordingly.len
, decrease the count of the character at the start of the window and update has_count
.has_count
equals unique
, increment res
.res
as the final result.