Stack

Stack

Master stack data structure with pattern-based problem solving

11 Problems
Intermediate
Watch Playlist

All Problems

11 problems
1
Nearest Greater to Right
Given an array of integers, find the nearest greater element to the right for each element. If no such element exists, consider it -1.
Medium
Not Attempted
Video
2
Nearest Greater to Left
Given an array of integers, find the nearest greater element to the left for each element. If no such element exists, consider it -1.
Medium
Not Attempted
Video
3
Nearest Smaller to Left
Given an array of integers, find the nearest smaller element to the left for each element. If no such element exists, consider it -1.
Medium
Not Attempted
Video
4
Nearest Smaller to Right
Given an array of integers, find the nearest smaller element to the right for each element. If no such element exists, consider it -1.
Medium
Not Attempted
Video
5
Stock Span Problem
The stock span problem is a financial problem where we have a series of n daily price quotes for a stock and we need to calculate the span of the stock's price for each day. The span of the stock's price on a given day is defined as the maximum number of consecutive days (including the given day and going backwards) for which the price of the stock on those days is less than or equal to its price on the given day.
Medium
Not Attempted
Video
6
Maximum Area Histogram
Find the largest rectangular area possible in a given histogram where the largest rectangle can be made of a number of contiguous bars. Assume that all bars have the same width of 1 unit.
Hard
Not Attempted
Video
7
Max Area Rectangle in Binary Matrix
Given a binary matrix filled with 0s and 1s, find the largest rectangle containing only 1s and return its area.
Hard
Not Attempted
Video
8
Rain Water Trapping
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.
Hard
Not Attempted
Video
9
Minimum Element in Stack in O(1) Space
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time and using constant extra space.
Hard
Not Attempted
Video
10
Delete Middle Element of a Stack
Given a stack, delete the middle element of it without using any additional data structure.
Medium
Not Attempted
Video
11
Reverse a Stack using Recursion
Given a stack, reverse it using recursion. You are not allowed to use any extra space other than the internal stack space used by recursion.
Medium
Not Attempted
Video