Heap

933. Number of Recent Calls

933. Number of Recent Calls 這個題目可以利用 min heap 可以保持排序的方式來檢查,只要

Kth Smallest Element in a Sorted Matrix

378. Kth Smallest Element in a Sorted Matrix 題目的要求是找到在一個排序好的組合矩陣中,找到第

1046. Last Stone Weight

1046. Last Stone Weight class Solution: def lastStoneWeight(self, stones:

703. Kth Largest Element in a Stream

703. Kth Largest Element in a Stream class KthLargest: def

215. Kth Largest Element in an Array

215. Kth Largest Element in an Array 需要透過 heap 來實作

295. Find Median from Data Stream

295. Find Median from Data Stream 這題如果透過排序的話,就會很好做,在每次取出數值時,將記憶體中的每個數字排列好,

1167. Minimum Cost to Connect Sticks

1167. Minimum Cost to Connect Sticks 這個題目的要求是說,每次要兩兩地把兩個木棍黏在一起,目標是要把所有的木棍黏在一起,不過每次黏的時候,

692. Top K Frequent Words

692. Top K Frequent Words 直接透過 Heap 的特性來完成。 class Solution:

128. Longest Consecutive Sequence

128. Longest Consecutive Sequence 這一題的題目敘述寫的沒有非常清楚,在面試的時候要問清楚。沒寫清楚的地方是題目說了這是一個沒有排序過的陣列,但是實際上要找的字序列,並不是要按照原本題目的順序的。 例如題目中給的例子:

973. K Closest Points to Origin

973. K Closest Points to Origin 這一個題目要找的是 k 個最靠近原點的點,所以有兩個步驟要處理。