heap

Key Points

Thinking Patterns

An Example

Problems

Problems - Binary Heap Problem

Key Points

  1. Use array to present the Binary Heap. (完全二叉树)

Problems

Problems Possible Solutions Key Points Code Comments
215. Kth Largest Element in an Array 1. Heap
2. Quick Sort
3. Quick Select
heap -

295. Get the median of an ordered stream

  • Key Point

    • Keep a max heap and min heap
    • May use the go built-in heap package

      • The up and down operation is a typical swim and sink operation of a heap
  • Principle

    • Using the heap sort. (if the stream is ordered, no need to order again)

results matching ""

    No results matching ""