454. 四數(shù)相加 II[https://leetcode.cn/problems/4sum-ii/] 思路example四個(gè)數(shù)組相同長(zhǎng)度第一步:brute-force: h...
204. Count Primes[https://leetcode.cn/problems/count-primes/] 思路example素?cái)?shù)篩選法 n/2 + n/3 ...
DFS 島嶼系列題目 200. Number of Islands[https://leetcode.cn/problems/number-of-islands/] 思路ex...
如果節(jié)點(diǎn) p 和 q 連通的話(huà),一定擁有相同的根節(jié)點(diǎn) 復(fù)雜度:O(n) 平衡性?xún)?yōu)化, 復(fù)雜度:O(log n) 路徑壓縮進(jìn)一步壓縮每棵樹(shù)的高度,使樹(shù)高始終保持為常數(shù) Unio...
207. Course Schedule[https://leetcode.cn/problems/course-schedule/] 思路example有向圖 graph[...
前綴和 差分?jǐn)?shù)組的主要適用場(chǎng)景是頻繁對(duì)原始數(shù)組的某個(gè)區(qū)間的元素進(jìn)行增減。 如果你想對(duì)區(qū)間 nums[i..j] 的元素全部加 3,那么只需要讓 diff[i] += 3,然后...
303. Range Sum Query - Immutable[https://leetcode.cn/problems/range-sum-query-immutable...
小結(jié) 合并兩個(gè)有序鏈表 鏈表的分解 合并 k 個(gè)有序鏈表 尋找單鏈表的倒數(shù)第 k 個(gè)節(jié)點(diǎn) 尋找單鏈表的中點(diǎn) 判斷單鏈表是否包含環(huán)并找出環(huán)起點(diǎn) 判斷兩個(gè)單鏈表是否相交并找出交點(diǎn)...
('a' | ' ') = 'a'('A' | ' ') = 'a'('b' & '_') = 'B'('B' & '_') = 'B'('d' ^ ' ') = 'D'('...
657. 機(jī)器人能否返回原點(diǎn)[https://leetcode.cn/problems/robot-return-to-origin/] 思路example計(jì)數(shù) R - L ...
685. 冗余連接 II[https://leetcode.cn/problems/redundant-connection-ii/] 思路example有向圖,并查集 有根...
684. 冗余連接[https://leetcode.cn/problems/redundant-connection/] 思路example并查集 并查集主要有三個(gè)功能。尋...
841. 鑰匙和房間[https://leetcode.cn/problems/keys-and-rooms/] 思路example圖有向圖 (有起點(diǎn)和終點(diǎn))連通分支 (但是...
132. 分割回文串 II[https://leetcode.cn/problems/palindrome-partitioning-ii/] 思路example最少分割次數(shù)...
1221. 分割平衡字符串[https://leetcode.cn/problems/split-a-string-in-balanced-strings/] 思路examp...
52. N皇后 II[https://leetcode.cn/problems/n-queens-ii/] 思路example暴力回溯 復(fù)雜度. 時(shí)間:O(?), 空間: O...
129. 求根節(jié)點(diǎn)到葉節(jié)點(diǎn)數(shù)字之和[https://leetcode.cn/problems/sum-root-to-leaf-numbers/] 思路example遞歸:前...
925. 長(zhǎng)按鍵入[https://leetcode.cn/problems/long-pressed-name/] 思路example雙指針一個(gè)字符串一個(gè)指針遍歷比較, 計(jì)...
205. 同構(gòu)字符串[https://leetcode.cn/problems/isomorphic-strings/] 思路example假設(shè):t.length == s....