常用数据结构

1.Min Stack
Using two stacks.
The first one is the regular stack.
The second one only store minimum numbers if a smaller number comes.
Push(x)
a. stack.push(x)
b. 如果<=minStack的最小值,那么就minStack.push(x)
Pop()
a. stack.pop()
b. 如果==minStack.top(),那么就minStack.pop()
2.Implement Queue by Two Stacks
Q.Push(x): S1-Push(x)
Q.Pop(): if S2.empty() --> S1->S2; S2.pop() Q.Top(): Similar with Q.Pop()
3.Largest Rectangle in Histogram
4.rehashing
5.Longest Consecutive Sequence
6. LRU Cache重要
当往双向链表中增加一个数时超过容量了,删除头结点,新增节点放在尾部,当访问某个数时,把他对应的节点移到尾部,头部是Least Recently Used,尾部是Most Recently Used。
7.Heapify
8.data stream median用大堆和小堆辅助

你可能感兴趣的:(常用数据结构)