bool isPopOrder(int pushA[], int popA[], int length) { stack<int> st; int i = 0, j = 0; while(i < length && j < length) { st.push(pushA[i++]); while(!st.empty() && popA[j] == st.top()) { st.pop(); j++; } } return (st.empty() && j == length); }
博客园 © 2004-2025 浙公网安备 33010602011771号 浙ICP备2021040463号-3