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