Skip to content

Commit b1b7eb2

Browse files
authored
Add files via upload
1 parent 3c11aca commit b1b7eb2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Solution {
2+
public:
3+
4+
string reverseParentheses(string s) {
5+
int size = s.size();
6+
string ans = "";
7+
stack<int> st;
8+
for (int x = 0; x < size; ++x) {
9+
if (s[x] == '(') {
10+
st.push(x);
11+
}
12+
else if(s[x] == ')') {
13+
reverse(s.begin() + st.top(), s.begin() + x);
14+
st.pop();
15+
}
16+
}
17+
for (auto c : s) {
18+
if (c != '(' && c != ')') {
19+
ans += c;
20+
}
21+
}
22+
return ans;
23+
}
24+
};

0 commit comments

Comments
 (0)