1358. Number of Substrings Containing All Three Characters Medium
1/**
2 * [1358] Number of Substrings Containing All Three Characters
3 *
4 * Given a string s consisting only of characters a, b and c.
5 * Return the number of substrings containing at least one occurrence of all these characters a, b and c.
6 *
7 * Example 1:
8 *
9 * Input: s = "abcabc"
10 * Output: 10
11 * 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).
12 *
13 * Example 2:
14 *
15 * Input: s = "aaacb"
16 * Output: 3
17 * Explanation: The substrings containing at least one occurrence of the characters a, b and c are "aaacb", "aacb" and "acb".
18 *
19 * Example 3:
20 *
21 * Input: s = "abc"
22 * Output: 1
23 *
24 *
25 * Constraints:
26 *
27 * 3 <= s.length <= 5 x 10^4
28 * s only consists of a, b or c characters.
29 *
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/number-of-substrings-containing-all-three-characters/
34// discuss: https://leetcode.com/problems/number-of-substrings-containing-all-three-characters/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39 pub fn number_of_substrings(s: String) -> i32 {
40 0
41 }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn test_1358() {
52 }
53}
54
Back
© 2025 bowen.ge All Rights Reserved.