![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
栈
# 栈
lucky tiger
要一直前进,一直静下心来学习。
展开
-
力扣1190. 反转每对括号间的子串(栈的翻转)
给出一个字符串 s(仅含有小写英文字母和括号)。请你按照从括号内到外的顺序,逐层反转每对匹配括号中的字符串,并返回最终的结果。注意,您的结果中 不应 包含任何括号。示例 1:输入:s = "(abcd)"输出:"dcba"示例 2:输入:s = "(u(love)i)"输出:"iloveu"方法一:模拟遍历(栈的使用,把(之前的字符串放到栈里面,同时用一个字符串来记录(这后面的东西遇到)就翻转之前的字符串,翻转完前面要加上之前的栈保存的(前的东西)class So.原创 2021-05-28 19:08:34 · 140 阅读 · 0 评论 -
力扣 394 字符串解码 栈
1、2、3[a]2[bc]3 num= 3[ numstack : 3a cur=a] 迭代 strstack aaa cur=aaa stack pop2 num=2[ numstack : 2bc strstack.push(cur) cur.clear() strstack aaa] strstrack aaabcbc3、class Solution {public: string decodeString(s...原创 2020-05-29 09:24:22 · 179 阅读 · 0 评论 -
力扣 1021 删除最外层括号*********
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); .原创 2020-05-14 10:59:13 · 113 阅读 · 0 评论 -
力扣-155-最小栈
1、2、class MinStack {public: /** initialize your data structure here. */ MinStack() { } stack<int> minstack; stack<int>data; void push(int x) { data.push(x); if(minstack.empty()||x<=min原创 2020-05-12 16:46:14 · 203 阅读 · 0 评论