↓快轉到主要內容

Hard

LeetCode 239: Sliding Window Maximum
·1 分鐘
LeetCode Daily Hard Monotonic-Queue
LeetCode 解題紀錄
LeetCode 2402: Meeting Rooms III
·2 分鐘
LeetCode Hard Heap Sorting Simulation Intervals
LeetCode 2402 解題筆記:空閒房間和忙碌房間各一個 heap,延後的會議要保留原本的長度
LeetCode 927: Three Equal Parts
·2 分鐘
LeetCode Hard Math Array
LeetCode 927 解題筆記:三段的 1 一樣多,先數 1;第三段一定延伸到陣列尾端,它的長度決定每段要比對的內容,再檢查三段的位置不重疊
LeetCode 952: Largest Component Size by Common Factor
·2 分鐘
LeetCode Hard Math Number-Theory Union-Find Hash-Table Array
LeetCode 952 解題筆記:有共同因數 ⇔ 有共同的質因數;把每個數分解質因數,同一個質因數的 index 用 Union-Find 合併,不用兩兩算 GCD
LeetCode 3518: Smallest Palindromic Rearrangement II
·2 分鐘
LeetCode Hard Math Combinatorics Counting Hash-Table String
LeetCode 3518 解題筆記:回文由左半邊決定,變成「多重集合的第 k 個排列」;逐位試每個字元,用排列數判斷第 k 個落在哪個分支,排列數可以 O(1) 更新
LeetCode 2999: Count the Number of Powerful Integers
·1 分鐘
LeetCode Daily Hard Digit-Dp
LeetCode 解題紀錄
LeetCode 154: Find Minimum in Rotated Sorted Array II
·1 分鐘
LeetCode Hard Array Binary-Search
LeetCode 154 解題筆記:跟 LC 153 一樣跟右端比,相等時分不出斷點在哪一邊,只能 r -= 1;最壞 O(n)
LeetCode 42: Trapping Rain Water
·1 分鐘
LeetCode Hard Array Two-Pointers Dynamic-Programming Stack
LeetCode 42 解題筆記:每格能存的水是 min(左邊最高, 右邊最高) - 自己的高度;用前後綴最大值或左右雙指針