Number of Substrings Containing All Three Characters
Given a string `s` consisting only of the characters `a`, `b` and `c`, return the number of substrings containing at least one occurrence of each of these three characters.
30:00
Number of Substrings Containing All Three Characters
Given a string s consisting only of the characters a, b and c, return the number of substrings containing at least one occurrence of each of these three characters.
Example 1:
Input: {"s":"abcabc"}
Output: 10
Constraints:
3≤s.length≤5×104
s only consists of the characters a, b or c.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s":"abcabc"}
Count substrings by where they end. Remember the last index of a, b and c; -1 means not seen yet.