Topic links:
Ideas: The code attempts to simulate the corresponding sequence of the stack, if fails, it returns false, otherwise true
Implementation code:
Package niuke; Import the java.util.Stack; public class stack is pressed into the pop-up sequence { public Boolean IsPopOrder ( int [] PUSHA, int [] POPA) { Stack <Integer> = Stack new new Stack <> (); int I = 0 ; int J = 0 ; stack.push (PUSHA [I ++ ]); the while (J <popA.length) { // simulated stack the while (POPA [J] =! {stack.peek ()) IF ( == pushA.length I) return to false; stack.push(pushA[i++]); } stack.pop(); ++j; } return true; } }
Code has been ac
I hope to be helpful
the above