当前位置:网站首页>232. Implement queue with stack
232. Implement queue with stack
2022-07-03 12:11:00 【zwanying】
- Using stack to realize queue
Please use only two stacks to implement the FIFO queue . The queue should support all operations supported by the general queue (push、pop、peek、empty):
Push : Simulate queuing
Out of the stack : Simulate the queue
push: Append an element after the queue
pop: Delete the first element of the queue
peek: Get the first element of the queue
Be careful :
1、 Initialize two stacks , Must be outside the method , It's a class variable .
2、 Outgoing queue , When you move elements from in stack to out stack , You must ensure that there are no elements in the stack , otherwise , When adding an element again , It will cause disorder .
边栏推荐
- (construction notes) learn the specific technology of how to design reusable software entities from three levels: class, API and framework
- OpenGL index cache object EBO and lineweight mode
- Shardingsphere sub database and sub table < 3 >
- Test classification in openstack
- ArcGIS application (XXI) ArcMap method of deleting layer specified features
- Vulnhub's Nagini
- Redis notes 01: Introduction
- Use of QT OpenGL camera
- Symlink(): solution to protocol error in PHP artisan storage:link on win10
- Dart: view the dill compiled code file
猜你喜欢
随机推荐
typeScript
vulnhub之presidential
网络通讯之Socket-Tcp(一)
Pki/ca and digital certificate
vulnhub之narak
Use of QT OpenGL camera
023(【模板】最小生成树)(最小生成树)
Symlink(): solution to protocol error in PHP artisan storage:link on win10
QT OpenGL rotate, pan, zoom
STL tutorial 8-map
OpenGL shader use
Solution to the second weekly test of ACM intensive training of Hunan Institute of technology in 2022
Solve msvcp120d DLL and msvcr120d DLL missing
Shutter: about inheritedwidget
Shutter widget: centerslice attribute
牛牛的组队竞赛
Itext7 uses iexternalsignature container for signature and signature verification
(construction notes) grasp learning experience
Systemverilog-- OOP--对象的拷贝
(构造笔记)MIT reading部分学习心得