917. Reverse Only Letters Easy
1/**
2 * [917] Reverse Only Letters
3 *
4 * Given a string s, reverse the string according to the following rules:
5 *
6 * All the characters that are not English letters remain in the same position.
7 * All the English letters (lowercase or uppercase) should be reversed.
8 *
9 * Return s after reversing it.
10 *
11 * Example 1:
12 * Input: s = "ab-cd"
13 * Output: "dc-ba"
14 * Example 2:
15 * Input: s = "a-bC-dEf-ghIj"
16 * Output: "j-Ih-gfE-dCba"
17 * Example 3:
18 * Input: s = "Test1ng-Leet=code-Q!"
19 * Output: "Qedo1ct-eeLg=ntse-T!"
20 *
21 * Constraints:
22 *
23 * 1 <= s.length <= 100
24 * s consists of characters with ASCII values in the range [33, 122].
25 * s does not contain '\"' or '\\'.
26 *
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/reverse-only-letters/
31// discuss: https://leetcode.com/problems/reverse-only-letters/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36 pub fn reverse_only_letters(s: String) -> String {
37 String::new()
38 }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_917() {
49 }
50}
51
Back
© 2025 bowen.ge All Rights Reserved.