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 | C++ |
Valid Parentheses | C++ |
Min Stack | C++ |
心得:
①既然是stack主题.就要好好利用stack的特性–>LIFO后进先出
平衡符号:Problem1:Baseball Game
Problem2:Backspace String Compare
②可以使用两个stack来实现更多特性.
使用两个stack。可以逆转stack里的元素。就好像倒水一样Implement Queue using Stacks.这道题,就是用两个stack来实现queue
使用两个stack,因为都是栈,所以数据布局是一样的.也就是说:stack1保存完整数据.stack2保存特定数据.这两个stack的数据布局是一样的。(我感觉总结的不好,可能我也是有点蒙)。Min Stack这题用两个stack实现最小的数据布局.