class Solution {
public:
string removeOuterParentheses(string S) {
stack<char> sta;
string res;
for(auto c : S)
{
if(c==')') sta.pop();
if(!sta.empty()) res.push_back(c);
if(c=='(') sta.push(c);
}
return res;
}
};
力扣 1021 删除最外层括号*********
最新推荐文章于 2024-05-01 00:58:01 发布