地下室发现死老鼠,要找pest control吗?# Living
y*6
1 楼
Provide a data structure that can perform :
1. insert
2. delete
3. find min
4,. find max
5. delete min
6. delete max
all in O(1) time.
前面四个操作还好说,用一个hashtable和min stack, max stack就可以实现O(1)操作
,关键是operations 5&6,如果remove掉最小或者最大的元素,如何能找到second
smallest和second largest的元素?大牛们给一下提示? ^__^
1. insert
2. delete
3. find min
4,. find max
5. delete min
6. delete max
all in O(1) time.
前面四个操作还好说,用一个hashtable和min stack, max stack就可以实现O(1)操作
,关键是operations 5&6,如果remove掉最小或者最大的元素,如何能找到second
smallest和second largest的元素?大牛们给一下提示? ^__^