单调栈
单调栈:栈内的元素单调有序,分为单调增和单调减
伪码
for(int i=0;i<n;i++){
while(!st.empty() && vec[st.top()] < vec[i]){
st.pop();
do...
}
st.push(i);
}
单调栈:栈内的元素单调有序,分为单调增和单调减
伪码
for(int i=0;i<n;i++){
while(!st.empty() && vec[st.top()] < vec[i]){
st.pop();
do...
}
st.push(i);
}