
The count of substrings will always fit in a 32-bit integer.
For 'n' = 5, 's’ = “abbac”.
Answer is 3.
These are the only 3 valid substrings { “abbac”, ”bbac”, ”bac” } satisfying all the constraints.
The first line contains an integer 'n', representing the size of the input string ‘s’.
The second line contains a string 's' representing the input string.
Return the value as explained in the statement.
You don’t need to print anything, it has already been taken care of. Just complete the given function.
We will consider all possible substrings of the given string ‘s’. For each substring, we will check if it contains at least one occurrence of all the characters a, b, and c. If a substring satisfies this condition, we can count it towards our final answer.