当前位置:网站首页>5. < tag stack and general problems > supplement: lt.946 Verify the stack sequence (the same as the push in and pop-up sequence of offer 31. stack)
5. < tag stack and general problems > supplement: lt.946 Verify the stack sequence (the same as the push in and pop-up sequence of offer 31. stack)
2022-06-26 04:54:00 【Caicai's big data development path】
lt.946. Verify stack sequence
[ Case needs ]

[ Thought analysis ]

[ Code implementation ]
class Solution {
public boolean validateStackSequences(int[] pushed, int[] popped) {
//pushed First out of the stack , encounter poped The same elements of , Then take it. pop Full stack ;
Deque<Integer> stack = new LinkedList<>();
int i = 0;
for(int num : pushed){
stack.push(num);
while(!stack.isEmpty() && stack.peek() == popped[i]){
stack.pop();
++i;
}
}
return stack.isEmpty();
}
}
The specific problem solution : Am I
边栏推荐
- Use of better scroll
- 2.8 learning summary
- Datetime data type - min() get the earliest date and date_ Range() creates a date range, timestamp() creates a timestamp, and tz() changes the time zone
- 2022.2.11
- Method of saving pictures in wechat applet
- 排序查询
- JWT token authentication verification
- Stm8 MCU ADC sampling function is triggered by timer
- numpy 数据输入输出
- 2022.2.10
猜你喜欢

Zhimeng CMS will file a lawsuit against infringing websites

torchvision_transform(图像增强)

PSIM software learning ---08 call of C program block

Genius makers: lone Rangers, technology giants and AI | ten years of the rise of in-depth learning

【Latex】错误类型总结(持更)

Differences between TCP and UDP

2.< tag-动态规划和常规问题>lt.343. 整数拆分

1.21 learning summary

-Discrete Mathematics - Analysis of final exercises

UWB超高精度定位系统架构图
随机推荐
How can the intelligent transformation path of manufacturing enterprises be broken due to talent shortage and high cost?
torchvision_transform(图像增强)
date_ Range creation date range freq parameter value table and creation example
【Latex】错误类型总结(持更)
Multipass中文文档-使用Multipass服务授权客户端
Thinkphp6 parsing QR code
2022.2.17
2022.2.16
Multipass Chinese document - remove instance
2022.2.15
Multipass Chinese document - remote use of multipass
A ZABBIX self discovery script (shell Basics)
Image translation /gan:unsupervised image-to-image translation with self attention networks
2.22.2.14
Multipass Chinese document - setup driver
A method of quickly transplanting library function code to register code by single chip microcomputer
Genius makers: lone Rangers, technology giants and AI | ten years of the rise of in-depth learning
Is education important or ability important in software testing
dijkstra
做软件测试学历重要还是能力重要
