1941. Check if All Characters Have Equal Number of Occurrences Easy

@problem@discussion
#Hash Table#String#Counting



1/**
2 * [1941] Check if All Characters Have Equal Number of Occurrences
3 *
4 * Given a string s, return true if s is a good string, or false otherwise.
5 * A string s is good if all the characters that appear in s have the same number of occurrences (i.e., the same frequency).
6 *  
7 * Example 1:
8 * 
9 * Input: s = "abacbc"
10 * Output: true
11 * Explanation: The characters that appear in s are 'a', 'b', and 'c'. All characters occur 2 times in s.
12 * 
13 * Example 2:
14 * 
15 * Input: s = "aaabb"
16 * Output: false
17 * Explanation: The characters that appear in s are 'a' and 'b'.
18 * 'a' occurs 3 times while 'b' occurs 2 times, which is not the same number of times.
19 * 
20 *  
21 * Constraints:
22 * 
23 * 	1 <= s.length <= 1000
24 * 	s consists of lowercase English letters.
25 * 
26 */
27pub struct Solution {}
28
29// problem: https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences/
30// discuss: https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences/discuss/?currentPage=1&orderBy=most_votes&query=
31
32// submission codes start here
33
34impl Solution {
35    pub fn are_occurrences_equal(s: String) -> bool {
36        false
37    }
38}
39
40// submission codes end
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn test_1941() {
48    }
49}
50


Back
© 2025 bowen.ge All Rights Reserved.