LeetCode

1466. Reorder Routes to Make All Paths Lead to the City Zero

1466. Reorder Routes to Make All Paths Lead to the

643. Maximum Average Subarray I

643. Maximum Average Subarray I 題目不難,但是小細節很多,最差的情況是靠窮舉所有的項目來查看。 這個題目主要的考點是滑動窗口,是不是有辦法可以慢慢地控制好。

1456. Maximum Number of Vowels in a Substring of Given Length

1456. Maximum Number of Vowels in a Substring of Given

933. Number of Recent Calls

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

2336. Smallest Number in Infinite Set

2336. Smallest Number in Infinite Set 這個題目滿有趣的,側重在邏輯處理的部分,寫 code

189. Rotate Array

189. Rotate Array 直觀的做法是按照題目所敘述的方式,每次把最後的數字放到最前面,在把剩餘的數字慢慢向後移。 假設有 n 個元素,有

1584. Min Cost to Connect All Points

這一題如果不用 UnionFind 的確會有點難做。 class UnionFind: def __init__(self, size): self.

UnionFind

Quick Find class UnionFind: def __init__(self, size): self.root

276. Paint Fence

276. Paint Fence class Solution: def numWays(self, n: int,

1091. Shortest Path in Binary Matrix

1091. Shortest Path in Binary Matrix 可以先練習這些題目 * 200. Number of