栈
无
旺 崽
这个作者很懒,什么都没留下…
展开
-
Leetcode 150 逆波兰表达式求值
题目链接根据逆波兰表示法,求表达式的值。有效的算符包括 +、-、*、/ 。每个运算对象可以是整数,也可以是另一个逆波兰表达式。说明:整数除法只保留整数部分。给定逆波兰表达式总是有效的。换句话说,表达式总会得出有效数值且不存在除数为 0 的情况。示例 1:输入:tokens = ["2","1","+","3","*"]输出:9解释:该算式转化为常见的中缀算术表达式为:((2 + 1) * 3) = 9示例 2:输入:tokens = ["4","13","5","/","+"]输原创 2021-03-20 16:19:04 · 1729 阅读 · 0 评论 -
LeetCode 316 去除重复字母
LeetCode 316 去除重复字母题目链接给你一个字符串 s ,请你去除字符串中重复的字母,使得每个字母只出现一次。需保证 返回结果的字典序最小(要求不能打乱其他字符的相对位置)。示例 1:输入:s = "bcabc"输出:"abc"示例 2:输入:s = "cbacdcbc"输出:"acdb"简单栈操作,AC代码如下:class Solution {public: string removeDuplicateLetters(string s) {原创 2020-12-28 18:24:16 · 2708 阅读 · 0 评论 -
牛客编程巅峰赛S2第5场 - 钻石&王者 B.牛牛与后缀表达式
牛客编程巅峰赛S2第5场 - 钻石&王者 B.牛牛与后缀表达式题目链接题目描述给定牛牛一个后缀表达式s,计算它的结果,例如,1+1对应的后缀表达式为1#1#+,‘#’作为操作数的结束符号。其中,表达式中只含有‘+’、’-‘、’*‘三种运算,不包含除法。本题保证表达式一定合法,且计算过程和计算结果的绝对值一定不会超过10^{18}1018示例1输入"1#1#+"返回值2示例2输入"12#3#+15#*"返回值225简单栈操作,用一个数据栈存数字,用一个符号栈存原创 2020-12-01 21:26:20 · 2323 阅读 · 0 评论 -
HDUOJ 6799 Parentheses Matching
HDUOJ 6799 Parentheses Matching题目链接Problem DescriptionGiven a string P consisting of only parentheses and asterisk characters (i.e. “(”, “)” and “"), you are asked to replace all the asterisk characters in order to get a balanced parenthesis string with原创 2020-07-30 19:31:29 · 2435 阅读 · 0 评论 -
EOJ Monthly 2020.7 Sponsored by TuSimple A. 打字机
EOJ Monthly 2020.7 Sponsored by TuSimple A. 打字机题目链接感觉题解有些许复杂,我是这样想的:1.如果只用第一种操作,得到的肯定是一个只包含 aaa 的字符串,此时输出 Happy FangHappy\ FangHappy Fang2.如果只用第二种操作,我们可以这样想,把 aaa 当作左括号 (((,把 bbb 当作右括号 ))),那么就转化为判断合法的括号序列即可,如果匹配下来还剩 bbb,那么就输出 Dead FangD原创 2020-07-18 09:56:40 · 2431 阅读 · 0 评论 -
洛谷 P3056 [USACO12NOV]Clumsy Cows S
洛谷 P3056 [USACO12NOV]Clumsy Cows S题目链接题目描述Bessie the cow is trying to type a balanced string of parentheses into her new laptop, but she is sufficiently clumsy (due to her large hooves) that she keeps mis-typing characters. Please help her by computing原创 2020-07-17 17:20:32 · 2456 阅读 · 0 评论 -
Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) C.Unusual Competitions
Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) C.Unusual CompetitionsA bracketed sequence is called correct (regular) if by inserting “+” and “1” you can get a well-form...原创 2020-03-08 10:50:15 · 2228 阅读 · 0 评论