单调栈

cintang / 2023-05-07 / 原文

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

for(int i=0;i<n;i++){
    while(!st.empty() && vec[st.top()] < vec[i]){
        st.pop();
        do...
    }
    st.push(i);
}