File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ void swap (char & a, char & b) {
3
+ char _tmp = a;
4
+ a = b;
5
+ b = _tmp;
6
+ }
7
+
8
+
9
+ void help (vector<char > & s, int left, int right) {
10
+ if (left >= right)
11
+ return ;
12
+
13
+ swap (s[left], s[right]);
14
+
15
+ help (s, ++left, --right);
16
+ }
17
+
18
+ public:
19
+ void reverseString (vector<char >& s) {
20
+ help (s, 0 , s.size ()-1 );
21
+ }
22
+ };
Original file line number Diff line number Diff line change @@ -110,6 +110,9 @@ This repository is for small C and C++ programs I do outside of my school work.
110
110
- reverse only the characters in the string
111
111
- Leetcode problem found [ here] ( https://leetcode.com/problems/reverse-only-letters/ )
112
112
- reverseStr.cpp
113
+ - reverseStrRecursive.cpp
114
+ - recursively reverse vector
115
+ - Leetcode problem found [ here] ( https://leetcode.com/explore/learn/card/recursion-i/250/principle-of-recursion/1440/ )
113
116
- romanToDecimal.cpp
114
117
- given roman numerals, return a decimal number
115
118
- sortArrayByParity.cpp
You can’t perform that action at this time.
0 commit comments