Skip to content

Commit c632fdb

Browse files
committed
Sync LeetCode submission - Reverse String (rust)
1 parent adfabe0 commit c632fdb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

problems/reverse_string/solution.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
impl Solution {
2+
pub fn reverse_string(s: &mut Vec<char>) {
3+
let max = s.len() - 1;
4+
if s.len() == 0 {
5+
return;
6+
}
7+
let mut i = 0;
8+
9+
while i < max - i {
10+
s.swap(i, max - i);
11+
i += 1;
12+
}
13+
}
14+
15+
16+
}

0 commit comments

Comments
 (0)