Topic Description:
Enter a sequence of two integers, and the first sequence represents the stack's indentation order, and determine whether the second sequence is the pop-up order of the stack. Suppose all the numbers on the stack are not equal. For example, the sequence 1,2,3,4,5 is the indentation sequence of a stack, the sequence 4,5,3,2,1 is a pop-up sequence corresponding to the stack sequence, but 4,3,5,1,2 cannot be the pop-up sequence of the pressure stack sequence .
This problem examines the stack in the STL, same as the train station problem on the Zoj.
Class Solution {Public:bool ispoporder (vector<int> pushv,vector<int> POPV) {int len1 = Pushv.si
Ze (), len2 = Popv.size ();
if (len1 = = 0 | | len2 = 0) return false;
if (len1 = = 1 && len2 = 1) {if (pushv[0] = = Popv[0]) return true;
else return false;
} if (Len1!= len2) return false;
Stack<int> s;
int i = 0, j = 0;
while (I < len1 && J < len1) {if (S.empty () | | pushv[i]!= POPV[J]) {
S.push (Pushv[i]);
i++;
} if (pushv[i] = = Popv[j]) {i++;
j + +;
while (!s.empty () && popv[j] = = S.top () && J < len1) {s.pop ();
j + +;
}} if (j = = Len1) return true;
else return false; }
};