1876. Substrings of Size Three with Distinct Characters Easy

@problem@discussion
#Hash Table#String#Sliding Window#Counting



1/**
2 * [1876] Substrings of Size Three with Distinct Characters
3 *
4 * A string is good if there are no repeated characters.
5 * Given a string s​​​​​, return the number of good substrings of length three in s​​​​​​.
6 * Note that if there are multiple occurrences of the same substring, every occurrence should be counted.
7 * A substring is a contiguous sequence of characters in a string.
8 *  
9 * Example 1:
10 * 
11 * Input: s = "xyzzaz"
12 * Output: 1
13 * Explanation: There are 4 substrings of size 3: "xyz", "yzz", "zza", and "zaz". 
14 * The only good substring of length 3 is "xyz".
15 * 
16 * Example 2:
17 * 
18 * Input: s = "aababcabc"
19 * Output: 4
20 * Explanation: There are 7 substrings of size 3: "aab", "aba", "bab", "abc", "bca", "cab", and "abc".
21 * The good substrings are "abc", "bca", "cab", and "abc".
22 * 
23 *  
24 * Constraints:
25 * 
26 * 	1 <= s.length <= 100
27 * 	s​​​​​​ consists of lowercase English letters.
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters/
33// discuss: https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn count_good_substrings(s: String) -> i32 {
39        0
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_1876() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.