Amazon, Google, and Microsoft ask this problem. It introduces the monotonic stack pattern, which is a common interview topic. This pattern lets you solve Largest Rectangle in Histogram and Trapping Rain Water, both of which are harder and also frequently asked. Once you understand monotonic stacks, you can solve any "next greater element" problem in . The pattern appears in stock span problems, building visibility problems, and histogram problems.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/maang-interview-prep/stacks/daily-temperatures-why-this-problem
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████████████████████████████████████████████████████████████████████████████████████████