1-001 leetcode-72.Edit Distance
數(shù)據(jù)結(jié)構(gòu)
字符串
算法
動(dòng)態(tài)規(guī)劃
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
step1. find the lcs
step2. delete charaters, then the length of the longer is equal to the shorter
? len1= longer - shorter
step3. replace differnt characters
?len2= shorter - lcs
step4. minDistance = len1 + len2 = longer - lcs
1-002 leetcode-73.Set Matrix Zeroes
數(shù)據(jù)結(jié)構(gòu)
二維vector
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
常數(shù)空間
關(guān)鍵思路
1)利用第一行第一列來(lái)存儲(chǔ)哪些行列需要置為0
2)需要倒過(guò)來(lái)進(jìn)行填充,否則先填入第一行第一列會(huì)覆蓋掉信息
3)倒過(guò)來(lái)就有個(gè)問題,第一列需要額外進(jìn)行標(biāo)記、處理
1-003 leetcode-74.Search a 2D Matrix
數(shù)據(jù)結(jié)構(gòu)
vector
算法
二分查找
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
將二維數(shù)組當(dāng)成一維數(shù)組,下標(biāo)進(jìn)行適當(dāng)轉(zhuǎn)換變?yōu)槎粩?shù)組即可,進(jìn)行二分查找。
1-004 leetcode-75.Sort Colors
數(shù)據(jù)結(jié)構(gòu)
vector
算法
雙指針法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1.采用雙指針法
begin:指向?yàn)?的后面一個(gè),初始化為0
end:指向?yàn)?的第一個(gè),初始化為size()
i從前往后遍歷,直到i == end為止
2.特別注意,這里有一個(gè)循環(huán)不變式
begin前全為0
begin到i前全為1(因此,當(dāng)i指向?qū)?時(shí),交換i和begin后,begin和i都要++:特別容易出錯(cuò))
end后全為2
1-005 leetcode-76.Minimum Window Substring
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-006 leetcode-77.Combinations
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-007 leetcode-78.Subsets
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-008 leetcode-79.Word Search
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-009 leetcode-80.Remove Duplicates from Sorted Array II
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0010 leetcode-81. Search in Rotated Sorted Array II
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0011 leetcode-82. Remove Duplicates from Sorted List II
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0012 leetcode-83. Remove Duplicates from Sorted List
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0013 leetcode-84. Largest Rectangle in Histogram
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0014 leetcode-85. Maximal Rectangle
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0015 leetcode-86. Partition List
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0016 leetcode-87. Scramble String
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0017 leetcode-88. Merge Sorted Array
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0018 leetcode-89. Gray Code
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0019 leetcode-90. Subsets II
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0020 leetcode-91. Decode Ways
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0021 leetcode-92. Reverse Linked List II
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0022 leetcode-93. Restore IP Addresses
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0023 leetcode-94. Binary Tree Inorder Traversal
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0024 leetcode-95. Unique Binary Search Trees II
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0025 leetcode-96. Unique Binary Search Trees
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0026 leetcode-97. Interleaving String
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0027 leetcode-98. Validate Binary Search Tree
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0028 leetcode-99. Recover Binary Search Tree
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0029 leetcode-100. Same Tree
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
1-0030 leetcode-101. Symmetric Tree
數(shù)據(jù)結(jié)構(gòu)
算法
時(shí)間復(fù)雜度
空間復(fù)雜度
關(guān)鍵思路
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。