Skip to content

Commit 42abb75

Browse files
committed
Time: 22 ms (66.29%), Space: 23.1 MB (94.13%) - LeetHub
1 parent bf2de92 commit 42abb75

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
void recursion_helper(vector<char> &s, int start, int end){
4+
if(start >= end) return;
5+
char temp = s[start];
6+
s[start] = s[end];
7+
s[end] = temp;
8+
recursion_helper(s, start+1, end-1);
9+
}
10+
11+
void reverseString(vector<char>& s) {
12+
recursion_helper(s, 0, s.size()-1);
13+
}
14+
};
15+
16+
// Runtime: 24 ms, faster than 50.40% of C++ online submissions for Reverse String.
17+
// Memory Usage: 23.3 MB, less than 39.26% of C++ online submissions for Reverse String.

0 commit comments

Comments
 (0)