Tag: stack
Maximum area histogram
Write a program to find the maximum area under histogram or largest rectangle in a histogram. It's optimized solution can be obtained using stack.
Nearest smaller to left
Write a program to find the nearest smaller element to the left of each element in an array.
Nearest smaller to right
Write a program to find the nearest smaller element or next smaller element to the right of each element in an array.
Stock span problem
Stock span problem is a financial problem mostly asked in interviews and its optimized solution can be obtained using stack. Here is the solution of stock span problem with explanation using stack ...
Nearest greater to left
Write a program to find the nearest greater element or next greater to the left of each element in an array.
Stack using linked list
In this tutorial, we will implement a stack using linked list with their time and space complexity.
Stack using array
In this tutorial, we will implement a stack using array by using the fixed array and dynamic array method with their time and space complexity. Basically the size of the array in case fixed array i...
Nearest greater to right
Write a program to find the nearest greater element or next greater to the right of each element in an array.
Balanced brackets problem
Balanced brackets problem is one of the famous problems based on the stack and it has been asked in many interviews. Here is the solution to this problem in python and JavaScript.