38 Problems
Stacks & Queues
Master stacks & queues problems with detailed brute force and optimal solutions.
01
Implement Stack from Scratch
Click to view brute force and optimal solutions
02
Implement Queue from Scratch
Click to view brute force and optimal solutions
03
Implement 2 stack in an array
Click to view brute force and optimal solutions
04
Find the middle element of a stack
Click to view brute force and optimal solutions
05
Implement N stacks in an Array
Click to view brute force and optimal solutions
06
Check the expression has valid or Balanced parenthesis or not
Click to view brute force and optimal solutions
07
Reverse a String using Stack
Click to view brute force and optimal solutions
08
Design a Stack that supports getMin() in O(1) time and O(1) extra space
Click to view brute force and optimal solutions
09
Find the next Greater element
Click to view brute force and optimal solutions
10
The celebrity Problem
Click to view brute force and optimal solutions
11
Arithmetic Expression evaluation
Click to view brute force and optimal solutions
12
Evaluation of Postfix expression
Click to view brute force and optimal solutions
13
Implement a method to insert an element at its bottom without using any other data structure
Click to view brute force and optimal solutions
14
Reverse a stack using recursion
Click to view brute force and optimal solutions
15
Sort a Stack using recursion
Click to view brute force and optimal solutions
16
Merge Overlapping Intervals
Click to view brute force and optimal solutions
17
Largest rectangular Area in Histogram
Click to view brute force and optimal solutions
18
Length of the Longest Valid Substring
Click to view brute force and optimal solutions
19
Expression contains redundant bracket or not
Click to view brute force and optimal solutions
20
Implement Stack using Queue
Click to view brute force and optimal solutions
21
Implement Stack using Deque
Click to view brute force and optimal solutions
22
Stack Permutations (Check if an array is stack permutation of other)
Click to view brute force and optimal solutions
23
Implement Queue using Stack
Click to view brute force and optimal solutions
24
Implement n queue in an array
Click to view brute force and optimal solutions
25
Implement a Circular queue
Click to view brute force and optimal solutions
26
LRU Cache Implementation
Click to view brute force and optimal solutions
27
Reverse a Queue using recursion
Click to view brute force and optimal solutions
28
Reverse the first K elements of a queue
Click to view brute force and optimal solutions
29
Interleave the first half of the queue with second half
Click to view brute force and optimal solutions
30
Find the first circular tour that visits all Petrol Pumps
Click to view brute force and optimal solutions
31
Minimum time required to rot all oranges
Click to view brute force and optimal solutions
32
Distance of nearest cell having 1 in a binary matrix
Click to view brute force and optimal solutions
33
First negative integer in every window of size k
Click to view brute force and optimal solutions
34
Check if all levels of two trees are anagrams or not
Click to view brute force and optimal solutions
35
Sum of minimum and maximum elements of all subarrays of size k
Click to view brute force and optimal solutions
36
Minimum sum of squares of character counts in a given string after removing k characters
Click to view brute force and optimal solutions
37
Queue based approach or first non-repeating character in a stream
Click to view brute force and optimal solutions
38
Next Smaller Element
Click to view brute force and optimal solutions