3675. Minimum Operations to Transform String Medium
1/**
2 * [3675] Minimum Operations to Transform String
3 *
4 * You are given a string s consisting only of lowercase English letters.
5 * You can perform the following operation any number of times (including zero):
6 *
7 *
8 * Choose any character c in the string and replace every occurrence of c with the next lowercase letter in the English alphabet.
9 *
10 *
11 * Return the minimum number of operations required to transform s into a string consisting of only 'a' characters.
12 * Note: Consider the alphabet as circular, thus 'a' comes after 'z'.
13 *
14 * <strong class="example">Example 1:
15 * <div class="example-block">
16 * Input: <span class="example-io">s = "yz"</span>
17 * Output: <span class="example-io">2</span>
18 * Explanation:
19 *
20 * Change 'y' to 'z' to get "zz".
21 * Change 'z' to 'a' to get "aa".
22 * Thus, the answer is 2.
23 * </div>
24 * <strong class="example">Example 2:
25 * <div class="example-block">
26 * Input: <span class="example-io">s = "a"</span>
27 * Output: <span class="example-io">0</span>
28 * Explanation:
29 *
30 * The string "a" only consists of 'a' characters. Thus, the answer is 0.
31 * </div>
32 *
33 * Constraints:
34 *
35 * 1 <= s.length <= 5 * 10^5
36 * s consists only of lowercase English letters.
37 *
38 */
39pub struct Solution {}
40
41// problem: https://leetcode.com/problems/minimum-operations-to-transform-string/
42// discuss: https://leetcode.com/problems/minimum-operations-to-transform-string/discuss/?currentPage=1&orderBy=most_votes&query=
43
44// submission codes start here
45
46impl Solution {
47 pub fn min_operations(s: String) -> i32 {
48 0
49 }
50}
51
52// submission codes end
53
54#[cfg(test)]
55mod tests {
56 use super::*;
57
58 #[test]
59 fn test_3675() {
60 }
61}
62Back
© 2026 bowen.ge All Rights Reserved.