3389. Minimum Operations to Make Character Frequencies Equal Hard
1/**
2 * [3389] Minimum Operations to Make Character Frequencies Equal
3 *
4 * You are given a string s.
5 * A string t is called good if all characters of t occur the same number of times.
6 * You can perform the following operations any number of times:
7 *
8 * Delete a character from s.
9 * Insert a character in s.
10 * Change a character in s to its next letter in the alphabet.
11 *
12 * Note that you cannot change 'z' to 'a' using the third operation.
13 * Return the minimum number of operations required to make s good.
14 *
15 * <strong class="example">Example 1:
16 * <div class="example-block">
17 * Input: <span class="example-io">s = "acab"</span>
18 * Output: <span class="example-io">1</span>
19 * Explanation:
20 * We can make s good by deleting one occurrence of character 'a'.
21 * </div>
22 * <strong class="example">Example 2:
23 * <div class="example-block">
24 * Input: <span class="example-io">s = "wddw"</span>
25 * Output: <span class="example-io">0</span>
26 * Explanation:
27 * We do not need to perform any operations since s is initially good.
28 * </div>
29 * <strong class="example">Example 3:
30 * <div class="example-block">
31 * Input: <span class="example-io">s = "aaabc"</span>
32 * Output: <span class="example-io">2</span>
33 * Explanation:
34 * We can make s good by applying these operations:
35 *
36 * Change one occurrence of 'a' to 'b'
37 * Insert one occurrence of 'c' into s
38 * </div>
39 *
40 * Constraints:
41 *
42 * 3 <= s.length <= 2 * 10^4
43 * s contains only lowercase English letters.
44 *
45 */
46pub struct Solution {}
47
48// problem: https://leetcode.com/problems/minimum-operations-to-make-character-frequencies-equal/
49// discuss: https://leetcode.com/problems/minimum-operations-to-make-character-frequencies-equal/discuss/?currentPage=1&orderBy=most_votes&query=
50
51// submission codes start here
52
53impl Solution {
54 pub fn make_string_good(s: String) -> i32 {
55 0
56 }
57}
58
59// submission codes end
60
61#[cfg(test)]
62mod tests {
63 use super::*;
64
65 #[test]
66 fn test_3389() {
67 }
68}
69
Back
© 2025 bowen.ge All Rights Reserved.