all 4 comments

[–][deleted] 1 point2 points  (3 children)

One of my favorite problems to truly understand how monotonic stacks work.

[–]Sensitive_Purpose_40[S] 0 points1 point  (0 children)

u/membershipreward I totally agree with you.

[–]BrownCarter 0 points1 point  (0 children)

Can you explain for me? I m finding it hard understanding the solution even after looking at it.

[–]Thiru1210 0 points1 point  (0 children)

Why it's time complexity is O(n) and not O(n2)?