Algorithm in LeetCode —— Stack

Stack 的 Tips:

  • 括号匹配问题及类似问题。第 20 题,第 921 题,第 1021 题。
  • 栈的基本 pop 和 push 操作。第 71 题,第 150 题,第 155 题,第 224 题,第 225 题,第 232 题,第 946 题,第 1047 题。
  • 利用栈进行编码问题。第 394 题,第 682 题,第 856 题,第 880 题。
  • 单调栈利用栈维护一个单调递增或者递减的下标数组。第 84 题,第 456 题,第 496 题,第 503 题,第 739 题,第 901 题,第 907 题,第 1019 题。
TitleSolutionDifficultyTimeSpace收藏
20. Valid ParenthesesGoEasyO(log n)O(1)
42. Trapping Rain WaterGoHardO(n)O(1)❤️
71. Simplify PathGoMediumO(n)O(n)❤️
84. Largest Rectangle in HistogramGoMediumO(n)O(n)❤️
94. Binary Tree Inorder TraversalGoMediumO(n)O(1)
103. Binary Tree Zigzag Level Order TraversalGoMediumO(n)O(n)
144. Binary Tree Preorder TraversalGoMediumO(n)O(1)
145. Binary Tree Postorder TraversalGoHardO(n)O(1)
150. Evaluate Reverse Polish NotationGoMediumO(n)O(1)
155. Min StackGoEasyO(n)O(n)
173. Binary Search Tree IteratorGoMediumO(n)O(1)
224. Basic CalculatorGoHardO(n)O(n)
225. Implement Stack using QueuesGoEasyO(n)O(n)
232. Implement Queue using StacksGoEasyO(n)O(n)
331. Verify Preorder Serialization of a Binary TreeGoMediumO(n)O(1)
394. Decode StringGoMediumO(n)O(n)
402. Remove K DigitsGoMediumO(n)O(1)
456. 132 PatternGoMediumO(n)O(n)
496. Next Greater Element IGoEasyO(n)O(n)
503. Next Greater Element IIGoMediumO(n)O(n)
636. Exclusive Time of FunctionsGoMediumO(n)O(n)
682. Baseball GameGoEasyO(n)O(n)
726. Number of AtomsGoHardO(n)O(n)❤️
735. Asteroid CollisionGoMediumO(n)O(n)
739. Daily TemperaturesGoMediumO(n)O(n)
844. Backspace String CompareGoEasyO(n)O(n)
856. Score of ParenthesesGoMediumO(n)O(n)
880. Decoded String at IndexGoMediumO(n)O(n)
895. Maximum Frequency StackGoHardO(n)O(n)
901. Online Stock SpanGoMediumO(n)O(n)
907. Sum of Subarray MinimumsGoMediumO(n)O(n)❤️
921. Minimum Add to Make Parentheses ValidGoMediumO(n)O(n)
946. Validate Stack SequencesGoMediumO(n)O(n)
1003. Check If Word Is Valid After SubstitutionsGoMediumO(n)O(1)
1019. Next Greater Node In Linked ListGoMediumO(n)O(1)
1021. Remove Outermost ParenthesesGoMediumO(n)O(1)
1047. Remove All Adjacent Duplicates In StringGoMediumO(n)O(1)