• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
July 18, 2024 |19.2K Views

Design and Implement Special Stack Data Structure

  Share  1 Like
Description
Discussion

Design a Data Structure SpecialStack that supports all the stack operations like push(), pop(), isEmpty(), isFull() and an additional operation getMin() which should return minimum element from the SpecialStack. All these operations of SpecialStack must be O(1). 

To implement SpecialStack, you should only use standard Stack data structure and no other data structure like arrays, list,

Example: 

Consider the following SpecialStack 16  --> TOP 15 29 19 18 When getMin() is called it should return 15, which is the minimum element in the current stack. If we do pop two times on stack, the stack becomes 29  --> TOP 19 18 When getMin() is called, it should return 18 which is the minimum in the current stack.

Design and Implement Special Stack Data Structure : https://www.geeksforgeeks.org/design-and-implement-special-stack-data-structure/