单调栈

单调栈:栈内的元素单调有序,分为单调增和单调减
伪码

for(int i=0;i<n;i++){
    while(!st.empty() && vec[st.top()] < vec[i]){
        st.pop();
        do...
    }
    st.push(i);
}
posted @ 2023-05-06 22:45  muzixuanxuanxuan  阅读(22)  评论(0)    收藏  举报