Skip to content

单调栈 | LearningGp #17

Description

@LearningGp

https://arvinhe.club/2020/06/20/%E5%8D%95%E8%B0%83%E6%A0%88/#more

单调栈
定义
单调栈就是满足单调性的栈结构。
性质

单调栈里的元素具有单调性;
每个元素在入栈前,将栈顶破坏栈单调性的元素都出栈;
使用单调栈可以找到入栈时元素向左遍历到的第一个比他小(大)的元素;出栈时元素向右遍历第一个比他小(大)的元素。(做题大多依靠这条性质)

例题
739 每日温度
题目描述
请根据每日 气温 列表,重新生成一个列表。对应位置的输出为:要想观测到

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions