LeetCode

265. Paint House II

265. Paint House II 我是基於 256. Paint House 去將之前的狀態給泛化,不過這樣的時間雜度是

256. Paint House

256. Paint House class Solution: def minCost(self, costs: List[

143. Reorder List

143. Reorder List # Definition for singly-linked list. # class ListNode: # def

1762. Buildings With an Ocean View

1762. Buildings With an Ocean View 這個題目的設計其實滿簡單的,因為我們有一個基礎的海平面高度為零,又由於海平面在所有建築物的右邊,因此可以透過反向的遍歷來找出所有可以看到海的建築物。

2461. Maximum Sum of Distinct Subarrays With Length K

2461. Maximum Sum of Distinct Subarrays With Length K 這個題目的的困難點是如何記錄獨一無二的數字:

1423. Maximum Points You Can Obtain from Cards

1423. Maximum Points You Can Obtain from Cards 我一開始的想法是,基礎的答案就會是前

2211. Count Collisions on a Road

2211. Count Collisions on a Road 這個題目我的想法可能過於複雜,不過應該是有包含所有的情景了。 我的思路主要就是透過目前車子的狀態跟左方車子前進的方向來去決定碰撞的情況。 class

3432. Count Partitions with Even Sum Difference

3432. Count Partitions with Even Sum Difference class Solution: def

93. Restore IP Addresses

93. Restore IP Addresses 參考 131. Palindrome Partitioning class Solution:

131. Palindrome Partitioning

131. Palindrome Partitioning class Solution: def partition(self, s: str)