344. Reverse String Easy

@problem@discussion
#Two Pointers#String



1/**
2 * [344] Reverse String
3 *
4 * Write a function that reverses a string. The input string is given as an array of characters s.
5 * You must do this by modifying the input array <a href="https://en.wikipedia.org/wiki/In-place_algorithm" target="_blank">in-place</a> with O(1) extra memory.
6 *  
7 * Example 1:
8 * Input: s = ["h","e","l","l","o"]
9 * Output: ["o","l","l","e","h"]
10 * Example 2:
11 * Input: s = ["H","a","n","n","a","h"]
12 * Output: ["h","a","n","n","a","H"]
13 *  
14 * Constraints:
15 * 
16 * 	1 <= s.length <= 10^5
17 * 	s[i] is a <a href="https://en.wikipedia.org/wiki/ASCII#Printable_characters" target="_blank">printable ascii character</a>.
18 * 
19 */
20pub struct Solution {}
21
22// problem: https://leetcode.com/problems/reverse-string/
23// discuss: https://leetcode.com/problems/reverse-string/discuss/?currentPage=1&orderBy=most_votes&query=
24
25// submission codes start here
26
27impl Solution {
28    pub fn reverse_string(s: &mut Vec<char>) {
29        
30    }
31}
32
33// submission codes end
34
35#[cfg(test)]
36mod tests {
37    use super::*;
38
39    #[test]
40    fn test_344() {
41    }
42}
43


Back
© 2025 bowen.ge All Rights Reserved.