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).
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).
相关文章推荐
- Implement a stack that pops out the mostfrequently added item. Stack supports 3 functions – push,
- CareerCup Output the amount of all possible strings of length N that don't of have consecutive a,b,c
- CareerCup Find out the winning probability given n, m and x
- CareerCup Find the smallest range that includes at least one number from each of the k sorted lists.
- CareerCup Find the biggest interval that has all its members in list in O(n)
- CareerCup Finds all the elements that appear more than n/3 times in the list
- CareerCup Write a function that given a position returns the digit in that 0123456789101112131415..
- CareerCup Find the no. of expressions that evaluate to a Walprime
- a interface to stack that implement use the fixed array.
- CareerCup Fill the array with product of all numbers except the number in that cell
- CareerCup Compute the rearrangement of x that is closest to y but still greater than y
- what's the difference between carry out/conduct/execute/implement/perform?
- a very good guide to makethe Most Out of the SQL Server 2005 Performance Dashboard
- identify internal components that are stealing the most pages from buffer pool using the following DMV query
- 【tomcat】There are no resources that can be added or removed from the server
- csharp: using OleDb Getting the identity of the most recently added record
- CareerCup Arrange the 2 x 1 boards on the 2 x n board
- Error retrieving parent for item: No resource found that matches the given name 'android:TextAppeara
- CareerCup how will you test if the random number generator is generating actual random numbers
- There are no resources that can be added or removed from the server. .