Standard Bar Sliding Window · Medium Problems O(n) · O(1)
A warehouse's floor plan is encoded as a strip where each position is zone A, B, or C. Compliance requires every audit team to cover a contiguous stretch that touches all three zone types at least once. The planner counts how many distinct stretches qualify — teams differ by where they start and end, not by which zones they see.
Input: A string s consisting only of 'a', 'b', and 'c'.
Output: Return the number of substrings that contain at least one 'a', one 'b', and one 'c'.
3 <= s.length <= 5 * 10^4s consists only of 'a', 'b', 'c'Input: {"s":"abcabc"}
Output: 10
Every stretch ending at index 3 or later qualifies; the count follows each right edge's earliest legal start.
Input: {"s":"aaacb"}
Output: 3
Only stretches that reach the final 'c' and also touch 'a' and 'b' qualify.