Skip to content

Category Archives: Stack

  Evaluate an expression represented by a String. The expression can contain parentheses, you can assume parentheses are well-matched. For simplicity, you can assume only… Read More
Find the largest rectangular area possible in a given histogram where the largest rectangle can be made of a number of contiguous bars. For simplicity,… Read More
Find the largest rectangular area possible in a given histogram where the largest rectangle can be made of a number of contiguous bars. For simplicity,… Read More
  Prerequisite – Stack | Set 1 (Introduction) Infix expression:The expression of the form a op b. When an operator is in-between every pair of operands.Postfix… Read More
Given a set of time intervals in any order, merge all overlapping intervals into one and output the result which should have only mutually exclusive… Read More
We have discussed a simple iterative postorder traversal using two stacks in the previous post. In this post, an approach with only one stack is… Read More
We have discussed iterative inorder and iterative preorder traversals. In this post, iterative postorder traversal is discussed, which is more complex than the other two… Read More
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… Read More
The problem is opposite of this post. We are given a Queue data structure that supports standard operations like enqueue() and dequeue(). We need to… Read More
Given preorder traversal of a binary search tree, construct the BST. For example, if the given traversal is {10, 5, 1, 7, 40, 50}, then… Read More
In a party of N people, only one person is known to everyone. Such a person may be present in the party, if yes, (s)he… Read More
Create a data structure twoStacks that represents two stacks. Implementation of twoStacks should use only one array, i.e., both stacks should use the same array… Read More
Question: Design a Data Structure SpecialStack that supports all the stack operations like push(), pop(), isEmpty(), isFull() and an additional operation getMin() which should return… Read More
Spaghetti stack A spaghetti stack is an N-ary tree data structure in which child nodes have pointers to the parent nodes (but not vice-versa) Spaghetti… Read More
Given an array, print the Next Greater Element (NGE) for every element. The Next greater Element for an element x is the first greater element… Read More