← All problemsSign in

Count Substrings

CodeChefRating 1866Open on judge ↗

Let's call a string $X$ *interesting* if it satisfies the following conditions: - $X$ contains at least $K$ pairwise distinct characters - for any two characters $c_1$ and $c_2$ which appear in $X$, the frequency (number of occurrences) of $c_1$ in $X$ is equal to the frequency of $c_2$ in $X$ You are given a string $S$. Compute the number of interesting substrings of $S$. Two substrings are cons

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start