| 1 | class Solution { |
| 2 | public boolean validateStackSequences(int[] pushed, int[] popped) { |
| 3 | |
| 4 | int N = pushed.length; |
| 5 | Stack<Integer> stack = new Stack(); |
| 6 | |
| 7 | int j = 0; |
| 8 | for (int x: pushed) { |
| 9 | stack.push(x); |
| 10 | while (!stack.isEmpty() && j < N && stack.peek() == popped[j]) { |
| 11 | //��ͷԪ�س��ӣ�ջ��Ԫ�س�ջ |
| 12 | stack.pop(); |
| 13 | j++; |
| 14 | } |
| 15 | } |
| 16 | if (!stack.isEmpty()){ |
| 17 | return false; |
| 18 | } |
| 19 | return true; |
| 20 | } |
| 21 | } |
nothing calls this directly
no outgoing calls
no test coverage detected