摘要:
2. Min Stack Implement a stack with following functions: push(val) push val into the stack pop() pop the top element and return it min() return the sm 阅读全文
posted @ 2019-04-07 19:26
IreneZh
阅读(106)
评论(0)
推荐(0)
摘要:
思路: 数据结构:stack。遍历整个字符串,如果遇到左向括号( [ { 则入栈。如果遇到右向括号时,先检查栈是否为空,为空说明左右向括号数目不一致,返回false;不为空则弹出栈顶元素查看是否和右向括号匹配。遍历完,要return stack.isEmpty(); 确保栈内没有剩余。 代码: 代码 阅读全文
posted @ 2019-04-07 13:44
IreneZh
阅读(109)
评论(0)
推荐(0)

浙公网安备 33010602011771号