Notes: Random Thoughts on Code
Monotonic stack: You need to maintain the order yourself, and there is no ready-made container to use.
Leek
1. Daily temperature
The violent solution is a two-layer for loop, and the time complexity is O(n^2).
Monotonic stack usage rules: Usually it is a one-dimensional array. To find the position of the first element on the right or left of any element that is larger or smaller than itself, we must think that we can use a monotonic stack . The time complexity is O(n). Space complexity O(n).
Essence: space for time.
2. Next Larger Element One
3. Next Larger Element Two
4. Receive rainwater
Dachang interview classic questions. Ivy topic.
5. Largest Rectangle in Column Chart