Skip to content

Queue, Stack & Linked List Note

Xin Wan edited this page Jan 15, 2018 · 7 revisions

Queue

  • Usages: Breadth-First Search related problems.

典型问题

  • Stack1: is the only stack to store new elements when adding a new element into the queue.
  • Stack2: is the only stack to pop old element out of the queue. (When stack2 is empty, we move all data from stack1 to stack2 (if any)) time complexity: Push(): O(1) Pop(): O(n) -> Amortized time complexity O(1)

Stack

Linked List

Deque

Clone this wiki locally