Class Solution
-
- All Implemented Interfaces:
public final class Solution1941 - Check if All Characters Have Equal Number of Occurrences\.
Easy
Given a string
s, returntrueifsis a good string, orfalseotherwise.A string
sis good if all the characters that appear inshave the same number of occurrences (i.e., the same frequency).Example 1:
Input: s = "abacbc"
Output: true
Explanation: The characters that appear in s are 'a', 'b', and 'c'. All characters occur 2 times in s.
Example 2:
Input: s = "aaabb"
Output: false
Explanation: The characters that appear in s are 'a' and 'b'. 'a' occurs 3 times while 'b' occurs 2 times, which is not the same number of times.
Constraints:
1 <= s.length <= 1000sconsists of lowercase English letters.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final BooleanareOccurrencesEqual(String s)-
-
Method Detail
-
areOccurrencesEqual
final Boolean areOccurrencesEqual(String s)
-
-
-
-