921使括号有效的最小添加 Posted on 2020-04-30 Words count in article: 96 | Reading time ≈ 1 921使括号有效的最小添加 这题应该放到简单题中 下面是题目给出的代码123456class Solution {public: int minAddToMakeValid(string S) { }}; 下面是我给出的代码1234567891011121314151617class Solution {public: int minAddToMakeValid(string S) { stack<char>stk; for(auto c:S) { if(!stk.empty()&&stk.top()=='('&&c==')') { stk.pop(); } else { stk.push(c); } } return stk.size(); }}; -------------本文结束,感谢您的阅读------------- Post author: Jason Post link: https://jasonxqh.github.io/2020/04/30/921%E4%BD%BF%E6%8B%AC%E5%8F%B7%E6%9C%89%E6%95%88%E7%9A%84%E6%9C%80%E5%B0%8F%E6%B7%BB%E5%8A%A0/ Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.