Monotonous Increasing/Decreasing Stack

https://leetcode.com/problems/sum-of-subarray-minimums/discuss/178876/stack-solution-with-very-detailed-explanation-step-by-step
all those questions that can be solve in such kind of stack.
https://leetcode.com/problems/online-stock-span/discuss/168311/C%2B%2BJavaPython-O(1)

LC901. Online Stock Span Done
LC907 Sum of Subarray Minimums Done
LC828. Unique Letter String Done
LC891. Sum of Subsequence Widths Done
LC1130. Minimum Cost Tree From Leaf Values Done
LC856. Score of Parentheses Done
LC503. Next Greater Element II Done
LC496. Next Greater Element I Done
LC84. Largest Rectangle in Histogram Done
LC42. Trapping Rain Water Done
Remove K digits Done
Create Maximum Number Done
132 Pattern Done
Sliding windows Maximum Done
max Chunks to make sorted2 Done not done by stack but the same idea. can be done by stack

Similar problems are:
907. Sum of Subarray Minimums Done
496. Next Greater Element I Done
503. Next Greater Element II Done
456. 132 Pattern Done
739. Daily Temperatures
901. Online Stock Span Done
84. Largest Rectangle in Histogram Done
85. Maximal Rectangle Done
42. Trapping Rain Water Done
316. Remove Duplicate Letters Done
402. Remove K Digits Done
321. Create Maximum Number Done
1130. Minimum Cost Tree From Leaf Values Done

Monotonic Queue
LC239. Sliding Window Maximum Done
LC862. Shortest Subarray with Sum at Least K Done
those two problem is somewhat similar. we need to maintain a sliding window, whether it is fixed in length or not. this definited sounds like can be solved in deque, and it did.

posted @ 2020-06-09 09:54  EvanMeetTheWorld  阅读(20)  评论(0)    收藏  举报