Create a customized data structure which evaluates functions in O(1)
Create a customized data structure such that it has functions :-
All the functions should be of O(1)
Question Source : amazon interview questions
Become a success story instead of just reading about them. Prepare for coding interviews at Amazon and other top product-based companies with our Amazon Test Series. Includes topic-wise practice questions on all important DSA topics along with 10 practice contests of 2 hours each. Designed by industry experts that will surely help you practice and sharpen your programming skills. Wait no more, start your preparation today!
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 write.geeksforgeeks.org or mail your article to email@example.com. 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.