Min Stack - Design a Data Structure | The Code Mate

preview_player
Показать описание
Prefix Sum Approach - CP TacTics | Find Pivot Index | The Code Mate

Design a Data Structure - Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

push(x) -- Push element x onto stack.
pop() -- Removes the element on top of the stack.
top() -- Get the top element.
getMin() -- Retrieve the minimum element in the stack.


#minstack #datastructuredesign #programming #dataStructures #algorithms #coding #competitiveprogramming #google #java #codinginterview #problemsolving #facebook #amazon #oracle #linkedin
Рекомендации по теме
Комментарии
Автор

We can avoid creating two stack to store elements just by creating a stack of pair which would store stack element in first place and second element of a pair would be min to the point.

vikku_
Автор

Q.3 Implement a minstack in C by designing a stack with push, pop and min functions, where
min( ) will return the minimum value in the stack.
I need codes for the above exp.

monikumari
visit shbcf.ru