Number of Substrings Containing All Three Characters
MediumSliding Window
Decode it first. Clues, constraints, pattern and plan before any code.Given a string s made only of the letters a, b and c, return the number of substrings that contain at least one of each of the three letters.
s = "abcabc" → 10
s = "aaacb" → 3 ("aaacb", "aacb", "acb")
s = "abc" → 1Constraints
3 <= s.length <= 5 * 10^4sonly consists ofa,borccharacters.