This commit is contained in:
krahets
2024-01-09 16:00:33 +08:00
parent 5b029ad632
commit 09d346e64d
90 changed files with 11430 additions and 648 deletions

View File

@ -15,6 +15,10 @@
<link rel="canonical" href="https://www.hello-algo.com/en/chapter_stack_and_queue/">
<link rel="prev" href="../chapter_array_and_linkedlist/summary/">
<link rel="next" href="stack/">
<link rel="icon" href="../assets/images/favicon.png">
@ -22,7 +26,7 @@
<title>Stack and Queue - Hello Algo</title>
<title>Chapter 5.   Stack and Queue - Hello Algo</title>
@ -87,7 +91,7 @@
<div data-md-component="skip">
<a href="#stack-and-queue" class="md-skip">
<a href="#chapter-5-stack-and-queue" class="md-skip">
Skip to content
</a>
@ -122,7 +126,7 @@
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
Stack and Queue
Chapter 5. &nbsp; Stack and Queue
</span>
</div>
@ -1083,6 +1087,162 @@
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_6" checked>
<div class="md-nav__link md-nav__container">
<a href="./" class="md-nav__link md-nav__link--active">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17.36 20.2v-5.38h1.79V22H3v-7.18h1.8v5.38h12.56M6.77 14.32l.37-1.76 8.79 1.85-.37 1.76-8.79-1.85m1.16-4.21.76-1.61 8.14 3.78-.76 1.62-8.14-3.79m2.26-3.99 1.15-1.38 6.9 5.76-1.15 1.37-6.9-5.75m4.45-4.25L20 9.08l-1.44 1.07-5.36-7.21 1.44-1.07M6.59 18.41v-1.8h8.98v1.8H6.59Z"/></svg>
<span class="md-ellipsis">
Chapter 5. Stack and Queue
</span>
</a>
<label class="md-nav__link md-nav__link--active" for="__nav_6" id="__nav_6_label" tabindex="0">
<span class="md-nav__icon md-icon"></span>
</label>
</div>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_6_label" aria-expanded="true">
<label class="md-nav__title" for="__nav_6">
<span class="md-nav__icon md-icon"></span>
Chapter 5. Stack and Queue
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="stack/" class="md-nav__link">
<span class="md-ellipsis">
5.1 Stack
</span>
</a>
</li>
<li class="md-nav__item">
<a href="queue/" class="md-nav__link">
<span class="md-ellipsis">
5.2 Queue
</span>
</a>
</li>
<li class="md-nav__item">
<a href="deque/" class="md-nav__link">
<span class="md-ellipsis">
5.3 Double-ended Queue
</span>
</a>
</li>
<li class="md-nav__item">
<a href="summary/" class="md-nav__link">
<span class="md-ellipsis">
5.4 Summary
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
@ -1103,6 +1263,23 @@
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#chapter-contents" class="md-nav__link">
<span class="md-ellipsis">
Chapter Contents
</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
@ -1137,15 +1314,22 @@
<!-- Page content -->
<h1 id="stack-and-queue">Stack and Queue<a class="headerlink" href="#stack-and-queue" title="Permanent link">&para;</a></h1>
<h1 id="chapter-5-stack-and-queue">Chapter 5. &nbsp; Stack and Queue<a class="headerlink" href="#chapter-5-stack-and-queue" title="Permanent link">&para;</a></h1>
<div class="center-table">
<p><a class="glightbox" href="../assets/covers/chapter_stack_and_queue.jpg" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Stack and Queue" src="../assets/covers/chapter_stack_and_queue.jpg" /></a></p>
<p><a class="glightbox" href="../assets/covers/chapter_stack_and_queue.jpg" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Stack and Queue" class="cover-image" src="../assets/covers/chapter_stack_and_queue.jpg" /></a></p>
</div>
<div class="admonition abstract">
<p class="admonition-title">Abstract</p>
<p>Stacks are like stacking cats, while queues are like cats lining up.</p>
<p>They respectively represent the logical relationships of Last-In-First-Out (LIFO) and First-In-First-Out (FIFO).</p>
</div>
<h2 id="chapter-contents">Chapter Contents<a class="headerlink" href="#chapter-contents" title="Permanent link">&para;</a></h2>
<ul>
<li><a href="https://www.hello-algo.com/en/chapter_stack_and_queue/stack/">5.1 &nbsp; Stack</a></li>
<li><a href="https://www.hello-algo.com/en/chapter_stack_and_queue/queue/">5.2 &nbsp; Queue</a></li>
<li><a href="https://www.hello-algo.com/en/chapter_stack_and_queue/deque/">5.3 &nbsp; Double-ended Queue</a></li>
<li><a href="https://www.hello-algo.com/en/chapter_stack_and_queue/summary/">5.4 &nbsp; Summary</a></li>
</ul>
<!-- Source file information -->
@ -1164,13 +1348,110 @@ aria-label="Footer"
<!-- Link to previous page -->
<a
href="../chapter_array_and_linkedlist/summary/"
class="md-footer__link md-footer__link--prev"
aria-label="Previous: 4.5 Summary"
rel="prev"
>
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</div>
<div class="md-footer__title">
<span class="md-footer__direction">
Previous
</span>
<div class="md-ellipsis">
4.5 Summary
</div>
</div>
</a>
<!-- Link to next page -->
<a
href="stack/"
class="md-footer__link md-footer__link--next"
aria-label="Next: 5.1 Stack"
rel="next"
>
<div class="md-footer__title">
<span class="md-footer__direction">
Next
</span>
<div class="md-ellipsis">
5.1 Stack
</div>
</div>
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4Z"/></svg>
</div>
</a>
</nav>
<!-- Comment system -->
<h5 align="center" id="__comments">Feel free to drop your insights, questions or suggestions</h5>
<!-- Insert generated snippet here -->
<script
src="https://giscus.app/client.js"
data-repo="krahets/hello-algo"
data-repo-id="R_kgDOIXtSqw"
data-category="Announcements"
data-category-id="DIC_kwDOIXtSq84CSZk_"
data-mapping="pathname"
data-strict="1"
data-reactions-enabled="1"
data-emit-metadata="0"
data-input-position="top"
data-theme="preferred_color_scheme"
data-lang="en"
crossorigin="anonymous"
async
>
</script>
<!-- Synchronize Giscus theme with palette -->
<script>
var giscus = document.querySelector("script[src*=giscus]")
/* Set palette on initial load */
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate" ? "dark_dimmed" : "light"
giscus.setAttribute("data-theme", theme)
}
/* Register event handlers after documented loaded */
document.addEventListener("DOMContentLoaded", function() {
var ref = document.querySelector("[data-md-component=palette]")
ref.addEventListener("change", function() {
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate" ? "dark_dimmed" : "light"
/* Instruct Giscus to change theme */
var frame = document.querySelector(".giscus-frame")
frame.contentWindow.postMessage(
{ giscus: { setConfig: { theme } } },
"https://giscus.app"
)
}
})
})
</script>
</article>
</div>
@ -1192,6 +1473,44 @@ aria-label="Footer"
<footer class="md-footer">
<nav class="md-footer__inner md-grid" aria-label="Footer" >
<a href="../chapter_array_and_linkedlist/summary/" class="md-footer__link md-footer__link--prev" aria-label="Previous: 4.5 Summary">
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</div>
<div class="md-footer__title">
<span class="md-footer__direction">
Previous
</span>
<div class="md-ellipsis">
4.5 Summary
</div>
</div>
</a>
<a href="stack/" class="md-footer__link md-footer__link--next" aria-label="Next: 5.1 Stack">
<div class="md-footer__title">
<span class="md-footer__direction">
Next
</span>
<div class="md-ellipsis">
5.1 Stack
</div>
</div>
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4Z"/></svg>
</div>
</a>
</nav>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">