
Leetcode-stack
peanwang
这个作者很懒,什么都没留下…
展开
-
LeetCode 682. Baseball Game
682. Baseball Game解析简化版的逆波兰表达式。class Solution {public: int calPoints(vector<string>& ops) { int sum=0; int point=0; int point2 = 0; std::stack&lt...原创 2018-07-30 17:04:17 · 152 阅读 · 0 评论 -
LeetCode 496. Next Greater Element I
496. Next Greater Element I 解析这题我真的没搞懂什么意思,在discuss里.Confusing statement这个人解释的我才明白>﹏< 解析solution1: 暴力class Solution {public: vector<int> nextGreaterElement(vector<int&...原创 2018-07-30 21:41:20 · 131 阅读 · 0 评论 -
LeetCode 844. Backspace String Compare
844. Backspace String Compare 解析正如说见,第一次末尾,第二次100%。为什么呢,因为第一次我强行使用stack.但是效果很差。我明白了一个道理:stack是一种思想,而不是一种数据结构。就好像济公说的酒肉穿肠过 佛祖心中留,你用的不是stack,而是用的stack这种方法,思想( ̄▽ ̄)” solution:class Solution {...原创 2018-07-31 16:07:14 · 382 阅读 · 0 评论 -
LeetCode 232. Implement Queue using Stacks
232. Implement Queue using Stacks解析更新ing class MyQueue {public: /** Initialize your data structure here. */ MyQueue() { } /** Push element x to the back of queue. */ v...原创 2018-07-31 23:41:36 · 121 阅读 · 0 评论 -
LeetCode 225. Implement Stack using Queues
225. Implement Stack using Queues 解析和这题差不多的Implement Queues using Stack.更新ing solution:class MyStack {public: /** Initialize your data structure here. */ MyStack() { } /*...原创 2018-08-01 11:25:37 · 128 阅读 · 0 评论 -
LeetCode 20. Valid Parentheses
20. Valid Parentheses 解析更新ingclass Solution {public: bool isValid(string s) { stack<char> S; for(auto x:s){ switch(x){ case '(': ...原创 2018-08-02 09:10:33 · 118 阅读 · 0 评论 -
LeetCode 155. Min Stack
155. Min Stack解析这题不会写,(弱鸡(;´д`)ゞ)。看了discuss。C++using two stacks quite short and easy to understand。class MinStack {public: /** initialize your data structure here. */ MinStack() { ...原创 2018-08-02 21:28:29 · 163 阅读 · 0 评论 -
LeetCode Stack easy
Problems set Title Solution Baseball Game C++ Next Greater Element I C++ Backspace String Compare C++ Implement Queue using Stacks C++ Implement Stack using Queues...原创 2018-08-02 22:43:24 · 180 阅读 · 0 评论