您的位置:首页 > 产品设计 > UI/UE

CareerCup Implement a stack that pops out the most frequently added item

2014-03-12 09:55 477 查看
Implement a stack that pops out the most frequently added item. Stack supports 3 functions - push, pop,and top.
Give complexity of each functions in your implementation.

--------------------------------------------------------------

One
option is to combine heap (to get top) with hashtable (to find element in heap). That way insert is o(logn) and retrieval is o(1).
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐