Class Solution
- java.lang.Object
-
- g1301_1400.s1358_number_of_substrings_containing_all_three_characters.Solution
-
public class Solution extends Object
1358 - Number of Substrings Containing All Three Characters.Medium
Given a string
sconsisting only of characters a, b and c.Return the number of substrings containing at least one occurrence of all these characters a, b and c.
Example 1:
Input: s = “abcabc”
Output: 10
Explanation: The substrings containing at least one occurrence of the characters a, b and c are “abc”, “abca”, “abcab”, “abcabc”, “bca”, “bcab”, “bcabc”, “cab”, “cabc” and “abc” ( again ).
Example 2:
Input: s = “aaacb”
Output: 3
Explanation: The substrings containing at least one occurrence of the characters a, b and c are “aaacb”, “aacb” and “acb”.
Example 3:
Input: s = “abc”
Output: 1
Constraints:
3 <= s.length <= 5 x 10^4sonly consists of a, b or _c _characters.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
-
-
Method Detail
-
numberOfSubstrings
public int numberOfSubstrings(String s)
-
-