What would be the datastructure in following scenario? (Stack with maximum)
Posted
by Abhishek Jain
on Stack Overflow
See other posts from Stack Overflow
or by Abhishek Jain
Published on 2010-04-10T17:39:55Z
Indexed on
2010/05/28
4:21 UTC
Read the original article
Hit count: 201
homework
|data-structures
Please note that there is no limitation of memory. I need to insert int from 1 to 1000.
I can do the each of the following operations in constant order of time:
- push():adds to the top
- pop():removes the top element
- getMax(): returns the max element
Please suggest me appropriate datastructure.
© Stack Overflow or respective owner