Create a customized data structure such that it has functions :-
All the functions should be of O(1)
Question Source : amazon interview questions
1) create a custom stack of type structure with two elements, (element, min_till_now)
2) implement the functions on this custom data type
5 inserted successfully 7 inserted successfully 3 inserted successfully min element :: 3 removed successfully 2 inserted successfully 9 inserted successfully Last element :: 9 0 inserted successfully min element :: 0 removed successfully 11 inserted successfully min element :: 2
Time complexity : Each function runs in O(1)
This article is contributed by Mandeep Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Design and Implement Special Stack Data Structure | Added Space Optimized Version
- Design a data structure that supports insert, delete, search and getRandom in constant time
- Stack Data Structure (Introduction and Program)
- Find the element before which all the elements are smaller than it, and after which all are greater
- Introduction to Data Structures | 10 most commonly used Data Structures
- Important functions of STL Components in C++
- How to create mergable stack?
- Remove characters from the first string which are present in the second string
- Given a linked list which is sorted, how will you insert in sorted way
- Find the maximum element in an array which is first increasing and then decreasing
- Sort linked list which is already sorted on absolute values
- Find all elements in array which have at-least two greater elements
- Find a pair of elements swapping which makes sum of two arrays same
- Delete array elements which are smaller than next or become smaller
- Design a stack which can give maximum frequency element
- Design data structures and algorithms for in-memory file system
- Design the Data Structures(classes and objects)for a generic deck of cards
- Difference between Stack and Queue Data Structures
- Why companies like Amazon, Microsoft, Google focuses on Data Structures and Algorithms : Answered
- Amazon Data Engineer Internship interview experience