File tree 3 files changed +46
-0
lines changed
solution/0300-0399/0344.Reverse String
3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,23 @@ var reverseString = function (s) {
96
96
};
97
97
```
98
98
99
+ ### ** Rust**
100
+
101
+ ``` rust
102
+ impl Solution {
103
+ pub fn reverse_string (s : & mut Vec <char >) {
104
+ let n = s . len ();
105
+ let mut l = 0 ;
106
+ let mut r = n - 1 ;
107
+ while l < r {
108
+ s . swap (l , r );
109
+ l += 1 ;
110
+ r -= 1 ;
111
+ }
112
+ }
113
+ }
114
+ ```
115
+
99
116
### ** ...**
100
117
101
118
```
Original file line number Diff line number Diff line change @@ -90,6 +90,23 @@ var reverseString = function (s) {
90
90
};
91
91
```
92
92
93
+ ### ** Rust**
94
+
95
+ ``` rust
96
+ impl Solution {
97
+ pub fn reverse_string (s : & mut Vec <char >) {
98
+ let n = s . len ();
99
+ let mut l = 0 ;
100
+ let mut r = n - 1 ;
101
+ while l < r {
102
+ s . swap (l , r );
103
+ l += 1 ;
104
+ r -= 1 ;
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
93
110
### ** ...**
94
111
95
112
```
Original file line number Diff line number Diff line change
1
+ impl Solution {
2
+ pub fn reverse_string ( s : & mut Vec < char > ) {
3
+ let n = s. len ( ) ;
4
+ let mut l = 0 ;
5
+ let mut r = n - 1 ;
6
+ while l < r {
7
+ s. swap ( l, r) ;
8
+ l += 1 ;
9
+ r -= 1 ;
10
+ }
11
+ }
12
+ }
You can’t perform that action at this time.
0 commit comments