Skip to content

Commit

Permalink
19-InSange
Browse files Browse the repository at this point in the history
  • Loading branch information
InSange committed Jul 13, 2024
1 parent efcb945 commit f6d6058
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions InSange/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
| 16μ°¨μ‹œ | 2024.06.28 | κ·Έλž˜ν”„ | [Maximum_Total_Importance_ofRoads](https://leetcode.com/problems/maximum-total-importance-of-roads/) | [#16](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/63)]
| 17μ°¨μ‹œ | 2024.06.28 | λ¬Έμžμ—΄ | [Zigzag Conversion](https://leetcode.com/problems/zigzag-conversion/) | [#17](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/64)]
| 18μ°¨μ‹œ | 2024.07.10 | λ¬Έμžμ—΄ | [Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder/) | [#18](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/64)]
| 19μ°¨μ‹œ | 2024.07.13 | μŠ€νƒ | [Crawler Log Folder](https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses/) | [#19](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/64)]
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <iostream>
#include <stack>

using namespace std;

class Solution {
public:
string reverseParentheses(string s) {
stack<char> st;

string ans;
string word;

ans = "";

for (char c : s)
{
if (c == ')')
{
word = "";
while (!st.empty() && st.top() != '(') {
word += st.top();
st.pop();
}
if (!st.empty())
{
st.pop();
}
for (char w : word)
{
st.push(w);
}
}
else
{
st.push(c);
}
}

while (!st.empty())
{
ans = st.top() + ans;
st.pop();
}


return ans;
}
};

0 comments on commit f6d6058

Please sign in to comment.