/
githubmirror
/
LeetCodeAnimation
Обзор
Документация
Войти
/
githubmirror
/
LeetCodeAnimation
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
problems/0946--validate-stack-sequences/Code/1.java
21 строка
549 B
吴至波
docs: organize assets and add animation previews
10 июн 2026, 10:57
10 июн 2026, 10:57
3711846
Код
Авторство
О чём код?
class Solution { public boolean validateStackSequences(int[] pushed, int[] popped) { int N = pushed.length; Stack<Integer> stack = new Stack(); int j = 0; for (int x: pushed) { stack.push(x); while (!stack.isEmpty() && j < N && stack.peek() == popped[j]) { //��ͷԪ�س��ӣ�ջ��Ԫ�س�ջ stack.pop(); j++; } } if (!stack.isEmpty()){ return false; } return true; } }