Design a stack class which will return the most occurring number in the stack. If 2 numbers have the same count of occurrence then return the number which is at the top of stack. For this I was required to write the class with 2 methods push() & pop().
Sigiloso
I took it in different direction using List. Use HashMap with value as stack & return the required number from there. This way one can achieve O(1). This solution was given as a hint to me, else I wouldn't have thought about this.