Stacks Interview Questions

We're now moving on to stacks!

They are a container of objects that are inserted and removed according to the first-in, last-out principle. Stacks are a little more complex than lists, but they provide some useful additional functionality. The first element added to the stack is the last element removed, which makes them more like a traditional stack of plates in a cafe or diner. They're used to store data that might be added and removed many times, like undo information for a text editor, browser history or an undo command.

Section Menu

How do I use this section?

1. LESSON

The Gentle Guide to the Stack Data Structure

Objective: Welcome to this exciting lesson on stacks! Here's what you can expect to gain from it: Conceptual Understanding: Learn what stacks are, inside and out. Technical Proficiency: Understand the time complexities associated with stacks, and how they compare to other...

2. CHALLENGE

Balanced Brackets

As a software engineer, you'll often be asked to optimize programs. One of the easiest ways to do so is by the introduction of an additional data structure. Here's another classic problem along the same vein. We're provided a string like the following: "{[])}" that is inclusive of the following symbols: parentheses...

3. CHALLENGE

Implement a Stack With Minimum

Recall that a stack is an abstract data type modeling a collection of elements. Its primary operations are push (which adds an element to the top of the stack) and pop (which removes the most newest element). Traditionally, a stack can easily be implemented in many dynamic languages using an array (and its built-in methods)....

4. CHALLENGE

Build a Calculator

Let's build a very basic calculator by programming it! You've probably seen one that look similar to this: But we wo...

5. CHALLENGE

Trapping Rain Water

The Trapping Rain Water Challenge: A Deep Dive Imagine you're looking at an elevation map displaying rainfall over a region's landscape. The map consists of bars of varying heights, each representing different elevations. Can you determine the amount of rainwater that this uneven terrain can hold? ![Elevation Map](https://stora...

6. CHALLENGE

Minimum Parentheses Removal

A string that contains correctly ordered parenthesis (), is a valid parenthesis string. More specifically, it must meet the following conditions: It is an empty string or contains only lowercase characters. It can be written as AB (A concatenated with B), where A and B are valid strings. It can be written as (A), where A...