标签: Python
包含该标签的全部文章 "Python".
Monotonic Stacks from Scratch: Starting with the Next Greater Element
A from-zero introduction to monotonic stacks. Start with what a stack is, walk through the next greater element problem step by step with the stack drawn at every move, then cover the template, its variants, and related Top 100 problems.
LeetCode 42. Trapping Rain Water: Four Approaches, from Brute Force to Two Pointers
A Python walkthrough of Trapping Rain Water. Start from one key observation — the water above a bar depends on the shorter of the tallest bars on each side — then build up brute force, prefix maxima, two pointers, and a monotonic stack.