↓快轉到主要內容

Two-Pointers

LeetCode 1695: Maximum Erasure Value (Sliding Window)
·1 分鐘
LeetCode Daily Medium Array Sliding-Window Two-Pointers Hash-Set
LeetCode 解題紀錄
LeetCode 2441: Largest Positive Integer That Exists With Its Negative
·1 分鐘
LeetCode Easy Hash-Map Two-Pointers Sorting
LeetCode 2441 解題筆記:把正數和負數的絕對值分開放兩個 set,取交集的最大值;只用絕對值會把同號的重複數字誤判成一對
LeetCode 904: Fruit Into Baskets
·1 分鐘
LeetCode Daily Medium Sliding-Window Variable-Window Two-Pointers Hash-Map
LeetCode 解題紀錄 - 可變大小滑動窗口與雜湊表
LeetCode 76: Minimum Window Substring
·1 分鐘
LeetCode Daily Hard String Sliding-Window Variable-Window Two-Pointers Hash-Map
LeetCode 解題紀錄 - 可變大小滑動窗口與字符計數
LeetCode 1004: Max Consecutive Ones III
·1 分鐘
LeetCode Daily Medium Array Sliding-Window Two-Pointers Binary-Array
LeetCode 解題紀錄 - 可變大小滑動窗口與零計數
LeetCode 2410: Maximum Matching of Players With Trainers
·1 分鐘
LeetCode Medium Two-Pointers Greedy Sorting Array
LeetCode 2410 解題筆記:兩邊都排序後,用同向雙指針讓最弱的球員配最小的、夠用的教練
Sliding Window 滑動視窗
·5 分鐘
演算法 Sliding-Window Two-Pointers Hash-Table Monotonic-Queue
固定長度視窗、可變長度求最長 / 最短、數子陣列個數(最多 K 相減、至少 K 用 count += left)、單調佇列維護視窗最值
LeetCode 1768: Merge Strings Alternately
·1 分鐘
LeetCode Easy Two-Pointers String
LeetCode 1768 解題筆記:兩個指針輪流取字元,短的用完後接上長的剩下部分
LeetCode 2000: Reverse Prefix of Word
·1 分鐘
LeetCode Easy Two-Pointers String Stack
LeetCode 2000 解題筆記:找到 ch 第一次出現的位置 i,把 word[:i + 1] 反轉接上後面;找不到就原樣回傳
LeetCode 3069: Distribute Elements Into Two Arrays I
·1 分鐘
LeetCode Easy Array Two-Pointers Simulation
LeetCode 3069 解題筆記:照規則模擬:前兩個各放一邊,之後比較兩個陣列的最後一個,放到最後一個比較大的那邊
LeetCode 611: Valid Triangle Number
·1 分鐘
LeetCode Medium Array Two-Pointers Binary-Search Greedy
LeetCode 611 解題筆記:排序後固定最長邊 k,左右指針找兩短邊:和夠大時中間的都可以,一次加 j - i 個
LeetCode 165: Compare Version Numbers
·1 分鐘
LeetCode Medium Two-Pointers String
LeetCode 165 解題筆記:用 . 切開後轉成整數逐段比較,比較短的版本缺的段當作 0