Number of Substrings Containing All Three Characters LeetCode solution in Python
1# Runtime: 466 ms (Top 30.17%) | Memory: 14.4 MB (Top 31.83%)2class Solution:3def numberOfSubstrings(self, s: str) -> int:4start = 05end = 06counter = 07store = {"a": 0, "b": 0, "c": 0}89for end in range(len(s)):10store[s[end]] += 11112while store["a"] > 0 and store["b"] > 0 and store["c"] > 0:13counter += len(s) - end14store[s[start]] -= 115start += 11617return counter