Open In App

Design and Implement Special Stack Data Structure

Last Updated : 23 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

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, . etc. 

Note: The output of the code will be the value returned by getMin() function.

Examples: 

Input: [18, 19, 29, 15, 16]
Output: 15
Explanation: The minimum element of the stack is 15.

Input: stack: [34, 335, 1814, 86]
Output: 34
Explanation: The minimum element of the stack is 34.

Please refer Design a stack that supports getMin() in O(1) time for three different approaches to solve this problem.


Design and Implement Special Stack Data Structure
Article Tags :
Practice Tags :

Similar Reads

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy