Tagged: stacks

2

Sort a Stack Using Temporary Stack

“Sort a Stack Using Temporary Stack” is again one of the favorite technical interview problems based on stack data structure. Here, in this problem, we are given a stack and our task is to sort the elements of given stack using help of another temporary stack. The top of the...

Next Greater Frequency Element 2

Next Greater Frequency Element

“Next Greater Frequency Element” is a standard problem of stack data structure. Here, in this problem, we are given an array and our task is to write a program to find the next (right side) greater frequency element of every element. If for any particular element next greater frequency element...

0

Print Bracket Number

“Print Bracket Number” is a stack based basic problem asked in technical round of product- based company. Here, in this problem, we are given a expression string of balanced brackets and our task is to print the bracket number when the expression is being parsed. Example: Expression: (())() Bracket Number:...

0

Implement Two Stacks in a Single Array

“Implement Two Stacks in a Single Array” is a popular technical interview problem based on stack data structure. Here, we are given an array of size ‘n’ and our task is to implement two stacks in a single array. We need to ensure that the space in an array is...

0

Reverse a String Using Stack

“Reverse a String Using Stack” is a basic programming exercise problem based on stack data structure. Here, in this problem, we are given a string and our task is to reverse a given string using stack data structure. Example: String: Helpmestudybro Reversed String: orbydutsempleH   String: Programming is cool Reverse...

0

Length of Longest Valid Substring

“Length of Longest Valid Substring” is one of the famous technical and algorithmic interview problem based on stack data structure. Here, we are given a string consisting of open and closing parentheses and our task is to find the length of longest valid substring. Example: String: ((()() Length of Longest...

0

Largest Rectangular Area in Histogram

“Largest Rectangular Area in Histogram” is one of the favorite technical interview problem, asked in many product-based company interview. Problem: We are given a histogram made up of contiguous bars of same width. Our task is to find the largest possible rectangular area.  Example: Length of contiguous bars: {5, 7, 12,...

0

Implement Stack Using Linked List

“Implement Stack Using Linked List” is a popular programming problem asked in many technical and algorithmic interviews, based on both linked list and stack data structures. Here, we need to implement stack data structure using linked list data structure. We strictly recommend to read the following post before proceeding: Insert...

0

Merge Overlapping Intervals

“Merge Overlapping Intervals” is a standard application of stack data structure. Here, we have given set of intervals and our task is to merge all overlapping intervals and then print the resultant non-overlapping intervals. Example: The set of intervals are: (1,4) , ( 2,5) , (7,8) , ( 6,9). After merging...

0

Implement Queue Using Stacks

“Implement Queue using Stacks” is a classic interview problem based on stack and queue data structures. Here, we have given two stacks and our task is to implement queue using these two stack.  Stack contains basically two operations, including:  push and pop. To implement queue using given two stacks, we need to perform some...