3389. Minimum Operations to Make Character Frequencies Equal
Hard
50 Points
Hash Table
String
Dynamic Programming
Counting
Enumeration
You are given a string s.
A string t is called good if all characters of t occur the same number of times.
You can perform the following operations any number of times:
Note that you cannot change 'z' to 'a' using the third operation.
Return the minimum number of operations required to make s good.
Examples
Example 1
Input: s = "acab"
Output: 1
Explanation:
We can make s good by deleting one occurrence of character 'a' .
Example 2
Input: s = "wddw"
Output: 0
Explanation:
We do not need to perform any operations since s is initially good.
Example 3
Input: s = "aaabc"
Output: 2
Explanation:
We can make s good by applying these operations:
Constraints
3 <= s.length <= 2 * 104
s contains only lowercase English letters.
3389. Minimum Operations to Make Character Frequencies Equal
Hard
50 Points
Hash Table
String
Dynamic Programming
Counting
Enumeration
You are given a string s.
A string t is called good if all characters of t occur the same number of times.
You can perform the following operations any number of times:
Note that you cannot change 'z' to 'a' using the third operation.
Return the minimum number of operations required to make s good.
Examples
Example 1
Input: s = "acab"
Output: 1
Explanation:
We can make s good by deleting one occurrence of character 'a' .
Example 2
Input: s = "wddw"
Output: 0
Explanation:
We do not need to perform any operations since s is initially good.
Example 3
Input: s = "aaabc"
Output: 2
Explanation:
We can make s good by applying these operations:
Constraints
3 <= s.length <= 2 * 104
s contains only lowercase English letters.
Minimum Operations to Make Character Frequencies Equal - Practice Coding | SlaveCode