Skip to content

Commit afc98f9

Browse files
authored
344. Reverse String
344. Reverse String
1 parent 52e7540 commit afc98f9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

reverseString.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
void reverseString(vector<char>& s) {
4+
reversenow(s, 0, s.size()-1);
5+
}
6+
void reversenow(vector<char>& s, int start, int end) {
7+
if(start >=end) return;
8+
char temp = s[start];
9+
s[start] = s[end];
10+
s[end] = temp;
11+
12+
reversenow (s, start+1, end-1);
13+
}
14+
};

0 commit comments

Comments
 (0)