想找 "从当前元素向某一方向的第一个 (大于 / 小于) 自己的元素",就要靠单调栈来维护单调性,对应的是 (递减 / 递增)。

Max Tree

build the tree from leave to the root. Draw out how the tree is built and using this algorithms (one direction stack)

results matching ""

    No results matching ""