LeetCode

1167. Minimum Cost to Connect Sticks

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

322. Coin Change

322. Coin Change 題目會給定兩樣東西,一樣是總金額(amount),一樣是硬幣的面額(coins),題目要求我們找出透過不同的面額組合,找出使用最少枚硬幣的解法。

158. Read N Characters Given Read4 II - Call multiple times

158. Read N Characters Given Read4 II - Call multiple

876. Middle of the Linked List

876. Middle of the Linked List # Definition for singly-linked list.

692. Top K Frequent Words

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

92. Reverse Linked List II

92. Reverse Linked List II 這一題的難度是中等,可是實作上的細節非常多,迭代可以完成這個任務,可是真的很多邊角情況要處理,但是如果用遞迴的方式的話好處理很多,

242. Valid Anagram

242. Valid Anagram Anagram 有一個特性就是只要是 Anagram 每個字元的字數都會一樣多,因此一個解法是先計算出一個單字每個字元所出現的次數,接著是再見去另外一個單字,有出現的字元的字數。

1010. Pairs of Songs With Total Durations Divisible by 60

1010. Pairs of Songs With Total Durations Divisible by 60

340. Longest Substring with At Most K Distinct Character

340. Longest Substring with At Most K Distinct Character 159.

380. Insert Delete GetRandom O(1)

380. Insert Delete GetRandom O(1) class RandomizedSet: def __init_