Tap here to switch tabs
Problem
Submissions

Problem: Number of Substrings Containing All Three Characters

Number of Substrings Containing All Three Characters counts substrings of a string made from a, b, and c that contain at least one of each character, returning the total.

Statement

Given a string s that consists only of the characters 'a', 'b', and 'c', return the number of substrings that contain at least one occurrence of each of the three characters.

Constraints:

  • 3≤3 \leq s.length ≤5×104\leq 5 \times 10^4

  • s consists only of characters 'a', 'b', or 'c'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Substrings Containing All Three Characters

Number of Substrings Containing All Three Characters counts substrings of a string made from a, b, and c that contain at least one of each character, returning the total.

Statement

Given a string s that consists only of the characters 'a', 'b', and 'c', return the number of substrings that contain at least one occurrence of each of the three characters.

Constraints:

  • 3≤3 \leq s.length ≤5×104\leq 5 \times 10^4

  • s consists only of characters 'a', 'b', or 'c'.