Skip to content

Commit f308640

Browse files
authoredJun 4, 2024
Update and rename 344. Reverse String to 344. Reverse String.cpp
1 parent 30eacb1 commit f308640

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed
 

‎344. Reverse String

-9
This file was deleted.

‎344. Reverse String.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// using vector
2+
class Solution {
3+
public:
4+
void reverseString(vector<char>& s) {
5+
reverse(s.begin(),s.end());
6+
}
7+
};
8+
9+
// using iteration
10+
class Solution {
11+
public:
12+
void reverseString(vector<char>& s) {
13+
int l=0;
14+
int r = s.size()-1;
15+
while(l<=r){
16+
swap(s[l++],s[r--]);
17+
}
18+
}
19+
};

0 commit comments

Comments
 (0)
Please sign in to comment.