Resource · Guide or article
Stack
Stack fundamentals in a few lines: push, pop and peek, last-in first-out order, and the physical pile analogy behind the name.
Reviewed
Open the original: Stack (opens the original site in a new tab)Add to a roadmap
Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.
Source content: English
Read this in other languages: 简体中文, Русский, 日本語, Français, Português, 한국어, Українська In computer science, a stack is an abstract data type that serves as a collection of elements, with two principal operations: The order in which elements come off a stack gives rise to its alternative name, LIFO (last in, first out). Additionally, a peek operation may give access to the top without modifying the stack. The name "stack" for this type of structure comes from the analogy to a set of physical items stacked on top of each other, which makes it easy to take an item off the top of the stack, while getting to an item deeper in the stack may require taking off multiple other items first.
PrepKit overview
PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.
- Suited to
- The source does not state a level
- Format
- Reference
What it covers
- Push, pop and optional peek operations
- LIFO ordering illustrated with a diagram of a stack at runtime
How to use it
PrepKit study advice, not a claim made by the source.
Implement a min-stack that returns the current minimum in constant time, then use a plain stack to check balanced brackets.
Scope and limitations
No complexity figures, code discussion or problems on the page; the YouTube reference is the same video linked from the queue page.
Access and format
Short README on GitHub, trekhleb/javascript-algorithms (MIT), with seven translations. English, free to read.
Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88
Evidence behind this overview
- src/data-structures/stack/README.md
Pages that include this
Get the PrepKit newsletter
Optional. You don't need it to use PrepKit.