mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2026-02-02 18:39:09 +08:00
Merge branch 'youngyangyang04:master' into master
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
<p align="center">
|
||||
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
|
||||
<img src="../pics/训练营.png" width="1000"/>
|
||||
</a>
|
||||
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
|
||||
* [做项目(多个C++、Java、Go、测开、前端项目)](https://www.programmercarl.com/other/kstar.html)
|
||||
* [刷算法(两个月高强度学算法)](https://www.programmercarl.com/xunlian/xunlianying.html)
|
||||
* [背八股(40天挑战高频面试题)](https://www.programmercarl.com/xunlian/bagu.html)
|
||||
|
||||
|
||||
> 来看看栈和队列不为人知的一面
|
||||
@@ -13,7 +11,7 @@
|
||||
|
||||
如图所示:
|
||||
|
||||

|
||||

|
||||
|
||||
那么我这里再列出四个关于栈的问题,大家可以思考一下。以下是以C++为例,使用其他编程语言的同学也对应思考一下,自己使用的编程语言里栈和队列是什么样的。
|
||||
|
||||
@@ -48,7 +46,7 @@ C++标准库是有多个版本的,要知道我们使用的STL是哪个版本
|
||||
来说一说栈,栈先进后出,如图所示:
|
||||
|
||||
|
||||

|
||||

|
||||
|
||||
栈提供push 和 pop 等等接口,所有元素必须符合先进后出规则,所以栈不提供走访功能,也不提供迭代器(iterator)。 不像是set 或者map 提供迭代器iterator来遍历所有元素。
|
||||
|
||||
@@ -61,7 +59,7 @@ C++标准库是有多个版本的,要知道我们使用的STL是哪个版本
|
||||
从下图中可以看出,栈的内部结构,栈的底层实现可以是vector,deque,list 都是可以的, 主要就是数组和链表的底层实现。
|
||||
|
||||
|
||||

|
||||

|
||||
|
||||
**我们常用的SGI STL,如果没有指定底层实现的话,默认是以deque为缺省情况下栈的底层结构。**
|
||||
|
||||
@@ -93,7 +91,3 @@ std::queue<int, std::list<int>> third; // 定义以list为底层容器的队列
|
||||
|
||||
|
||||
|
||||
<p align="center">
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user