Max stack

Problem Statement The problem “Max stack” states to design a special stack which can perform these operations : push(x): push one element into the stack. top(): returns the element that is at the top of the stack. pop(): remove the element from the stack which is at the top. peekmax(): …

Read moreMax stack

Insert Delete GetRandom

In Insert Delete GetRandom problem we need to design a data structure that supports all following operations in average¬†O(1)¬†time. insert(val): Inserts an item val to the set if not already present. remove(val): Removes an item val from the set if present. getRandom: Returns a random element from the current set …

Read moreInsert Delete GetRandom

Find Median from data Stream

In Find Median from the data Stream problem, we have given that integers are being read from a data stream. Find the median of all the elements read so far starting from the first integer till the last integer. Example Input 1: stream[ ] = {3,10,5,20,7,6} Output : 3 6.5 …

Read moreFind Median from data Stream

LRU Cache Implementation

Least Recently Used (LRU) Cache is a type of method which is used to maintain the data such that the time required to use the data is the minimum possible. LRU algorithm used when the cache is full. We remove the least recently used data from the cache memory of …

Read moreLRU Cache Implementation