Skip to content

diguage/leetcode

Repository files navigation

LeetCode

友情支持

如果觉得对您有所帮助,看在D瓜哥码这么多字的辛苦上,请友情支持一下,D瓜哥感激不尽,😜

支付宝

微信

有些打赏的朋友希望可以加个好友,欢迎关注D瓜哥的微信公众号,这样就可以通过公众号的回复直接给我发信息。

wx jikerizhi
💡
公众号的微信号是: jikerizhi因为众所周知的原因,有时图片加载不出来。如果图片加载不出来可以直接通过搜索微信号来查找我的公众号。

LeetCode Problems

序号 标题 代码 题解 难度 备注

1

1. Two Sum

Java

题解

Easy

2

2. Add Two Numbers

Java

题解

Medium

3

3. Longest Substring Without Repeating Characters

Java

题解

Medium

4

4. Median of Two Sorted Arrays

Java

题解

Hard

5

5. Longest Palindromic Substring

Java

题解

Medium

6

6. ZigZag Conversion

Java

题解

Medium

7

7. Reverse Integer

Java

题解

Easy

8

8. String to Integer (atoi)

Java

题解

Medium

9

9. Palindrome Number

Java

题解

Easy

10

11. Container With Most Water

Java

题解

Medium

11

12. Integer to Roman

Java

题解

Medium

12

13. Roman to Integer

Java

题解

Easy

13

14. Longest Common Prefix

Java

题解

Easy

14

15. 3Sum

Java

题解

Medium

双指针

15

16. 3Sum Closest

Java

题解

Medium

16

17. Letter Combinations of a Phone Number

Java

题解

Medium

17

18. 4Sum

Java

题解

Medium

双指针

18

19. Remove Nth Node From End of List

Java

题解

Medium

19

20. Valid Parentheses

Java

题解

Easy

20

21. Merge Two Sorted Lists

Java

题解

Easy

21

22. Generate Parentheses

Java

题解

Medium

22

23. Merge k Sorted Lists

Java

题解

Hard

23

24. Swap Nodes in Pairs

Java

题解

Medium

24

26. Remove Duplicates from Sorted Array

Java

题解

Easy

25

27. Remove Element

Java

题解

Easy

26

28. Implement strStr()

Java

题解

Easy

27

29. Divide Two Integers

Java

题解

Medium

28

31. Next Permutation

Java

题解

Medium

29

33. Search in Rotated Sorted Array

Java

题解

Medium

30

34. Find First and Last Position of Element in Sorted Array

Java

题解

Medium

31

35. Search Insert Position

Java

题解

Easy

32

36. Valid Sudoku

Java

题解

Medium

33

37. Sudoku Solver

Java

题解

Hard

34

38. Count and Say

Java

题解

Easy

35

39. Combination Sum

Java

题解

Medium

36

40. Combination Sum II

Java

题解

Medium

37

41. First Missing Positive

Java

题解

Hard

38

42. Trapping Rain Water

Java

题解

Hard

单调栈

39

43. Multiply Strings

Java

题解

Medium

40

45. Jump Game II

Java

题解

Hard

41

46. Permutations

Java

题解

Medium

42

47. Permutations II

Java

题解

Medium

43

48. Rotate Image

Java

题解

Medium

44

49. Group Anagrams

Java

题解

Medium

45

50. Pow(x, n)

Java

题解

Medium

46

51. N-Queens

Java

题解

Hard

47

52. N-Queens II

Java

题解

Hard

48

53. Maximum Subarray

Java

题解

Easy

49

54. Spiral Matrix

Java

题解

Medium

50

55. Jump Game

Java

题解

Medium

51

56. Merge Intervals

Java

题解

Medium

52

57. Insert Interval

Java

题解

Hard

53

58. Length of Last Word

Java

题解

Easy

54

59. Spiral Matrix II

Java

题解

Medium

55

60. Permutation Sequence

Java

题解

Medium

56

61. Rotate List

Java

题解

Medium

57

62. Unique Paths

Java

题解

Medium

58

63. Unique Paths II

Java

题解

Medium

59

64. Minimum Path Sum

Java

题解

Medium

60

66. Plus One

Java

题解

Easy

61

67. Add Binary

Java

题解

Easy

62

69. Sqrt(x)

Java

题解

Easy

63

70. Climbing Stairs

Java

题解

Easy

64

71. Simplify Path

Java

题解

Medium

65

72. Edit Distance

Java

题解

Hard

66

73. Set Matrix Zeroes

Java

题解

Medium

67

75. Sort Colors

Java

题解

Medium

68

76. Minimum Window Substring

Java

题解

Hard

69

77. Combinations

Java

题解

Medium

70

78. Subsets

Java

题解

Medium

71

79. Word Search

Java

题解

Medium

72

80. Remove Duplicates from Sorted Array II

Java

题解

Medium

73

81. Search in Rotated Sorted Array II

Java

题解

Medium

74

82. Remove Duplicates from Sorted List II

Java

题解

Medium

75

83. Remove Duplicates from Sorted List

Java

题解

Easy

76

86. Partition List

Java

题解

Medium

77

88. Merge Sorted Array

Java

题解

Easy

78

89. Gray Code

Java

题解

Medium

79

90. Subsets II

Java

题解

Medium

80

91. Decode Ways

Java

题解

Medium

81

92. Reverse Linked List II

Java

题解

Medium

82

93. Restore IP Addresses

Java

题解

Medium

83

94. Binary Tree Inorder Traversal

Java

题解

Medium

84

95. Unique Binary Search Trees II

Java

题解

Medium

85

96. Unique Binary Search Trees

Java

题解

Medium

86

98. Validate Binary Search Tree

Java

题解

Medium

树形DP套路或中序遍历

87

99. Recover Binary Search Tree

Java

题解

Medium

Morris遍历

88

100. Same Tree

Java

题解

Easy

89

101. Symmetric Tree

Java

题解

Easy

90

102. Binary Tree Level Order Traversal

Java

题解

Medium

91

103. Binary Tree Zigzag Level Order Traversal

Java

题解

Medium

92

104. Maximum Depth of Binary Tree

Java

题解

Easy

93

105. Construct Binary Tree from Preorder and Inorder Traversal

Java

题解

Medium

迭代如何实现?

94

106. Construct Binary Tree from Inorder and Postorder Traversal

Java

题解

Medium

迭代如何实现?

95

107. Binary Tree Level Order Traversal II

Java

题解

Easy

96

108. Convert Sorted Array to Binary Search Tree

Java

题解

Easy

97

109. Convert Sorted List to Binary Search Tree

Java

题解

Medium

分治+中序遍历

98

110. Balanced Binary Tree

Java

题解

Easy

99

111. Minimum Depth of Binary Tree

Java

题解

Easy

Morris解法需要深入研究

100

112. Path Sum

Java

题解

Easy

101

113. Path Sum II

Java

题解

Medium

102

114. Flatten Binary Tree to Linked List

Java

题解

Medium

103

116. Populating Next Right Pointers in Each Node

Java

题解

Medium

104

117. Populating Next Right Pointers in Each Node II

Java

题解

Medium

105

118. Pascal’s Triangle

Java

题解

Easy

106

119. Pascal’s Triangle II

Java

题解

Easy

107

120. Triangle

Java

题解

Medium

108

121. Best Time to Buy and Sell Stock

Java

题解

Easy

109

122. Best Time to Buy and Sell Stock II

Java

题解

Easy

110

123. Best Time to Buy and Sell Stock III

Java

题解

Hard

111

125. Valid Palindrome

Java

题解

Easy

112

127. Word Ladder

Java

题解

Medium

113

129. Sum Root to Leaf Numbers

Java

题解

Medium

114

130. Surrounded Regions

Java

题解

Medium

115

131. Palindrome Partitioning

Java

题解

Medium

116

133. Clone Graph

Java

题解

Medium

117

134. Gas Station

Java

题解

Medium

118

135. Candy

Java

题解

Hard

119

136. Single Number

Java

题解

Easy

120

137. Single Number II

Java

题解

Medium

121

138. Copy List with Random Pointer

Java

题解

Medium

122

139. Word Break

Java

题解

Medium

123

141. Linked List Cycle

Java

题解

Easy

124

142. Linked List Cycle II

Java

题解

Medium

125

144. Binary Tree Preorder Traversal

Java

题解

Medium

126

145. Binary Tree Postorder Traversal

Java

题解

Easy

强化迭代

127

146. LRU Cache

Java

题解

Medium

128

148. Sort List

Java

题解

Medium

129

150. Evaluate Reverse Polish Notation

Java

题解

Medium

130

151. Reverse Words in a String

Java

题解

Medium

131

152. Maximum Product Subarray

Java

题解

Medium

132

153. Find Minimum in Rotated Sorted Array

Java

题解

Medium

133

154. Find Minimum in Rotated Sorted Array II

Java

题解

Hard

134

155. Min Stack

Java

题解

Easy

135

160. Intersection of Two Linked Lists

Java

题解

Easy

136

162. Find Peak Element

Java

题解

Medium

137

166. Fraction to Recurring Decimal

Java

题解

Medium

138

167. Two Sum II - Input array is sorted

Java

题解

Easy

139

169. Majority Element

Java

题解

Easy

140

171. Excel Sheet Column Number

Java

题解

Easy

141

172. Factorial Trailing Zeroes

Java

题解

Easy

142

175. Combine Two Tables

SQL

题解

Easy

143

176. Second Highest Salary

SQL

题解

Easy

144

179. Largest Number

Java

题解

Medium

145

188. Best Time to Buy and Sell Stock IV

Java

题解

Hard

146

189. Rotate Array

Java

题解

Easy

147

190. Reverse Bits

Java

题解

Easy

148

191. Number of 1 Bits

Java

题解

Easy

149

198. House Robber

Java

题解

Easy

150

199. Binary Tree Right Side View

Java

题解

Medium

递归+DFS解法有意思

151

200. Number of Islands

Java

题解

Medium

152

202. Happy Number

Java

题解

Easy

153

204. Count Primes

Java

题解

Easy

154

205. Isomorphic Strings

Java

题解

Easy

155

206. Reverse Linked List

Java

题解

Easy

156

207. Course Schedule

Java

题解

Medium

157

208. Implement Trie (Prefix Tree)

Java

题解

Medium

158

210. Course Schedule II

Java

题解

Medium

159

215. Kth Largest Element in an Array

Java

题解

Medium

160

217. Contains Duplicate

Java

题解

Easy

161

221. Maximal Square

Java

题解

Medium

162

222. Count Complete Tree Nodes

Java

题解

Medium

163

226. Invert Binary Tree

Java

题解

Easy

164

227. Basic Calculator II

Java

题解

Medium

165

230. Kth Smallest Element in a BST

Java

题解

Medium

166

231. Power of Two

Java

题解

Easy

167

232. Implement Queue using Stacks

Java

题解

Easy

168

234. Palindrome Linked List

Java

题解

Easy

169

235. Lowest Common Ancestor of a Binary Search Tree

Java

题解

Easy

二叉搜索树左大右小的特性

170

236. Lowest Common Ancestor of a Binary Tree

Java

题解

Medium

171

237. Delete Node in a Linked List

Java

题解

Easy

172

238. Product of Array Except Self

Java

题解

Medium

173

239. Sliding Window Maximum

Java

题解

Hard

174

240. Search a 2D Matrix II

Java

题解

Medium

175

242. Valid Anagram

Java

题解

Easy

176

257. Binary Tree Paths

Java

题解

Easy

177

268. Missing Number

Java

题解

Easy

178

278. First Bad Version

Java

题解

Easy

179

279. Perfect Squares

Java

题解

Medium

180

283. Move Zeroes

Java

题解

Easy

181

287. Find the Duplicate Number

Java

题解

Medium

182

289. Game of Life

Java

题解

Medium

183

295. Find Median from Data Stream

Java

题解

Hard

184

297. Serialize and Deserialize Binary Tree

Java

题解

Hard

注意思维误区!

185

300. Longest Increasing Subsequence

Java

题解

Medium

186

303. Range Sum Query - Immutable

Java

题解

Easy

187

304. Range Sum Query 2D - Immutable

Java

题解

Medium

188

309. Best Time to Buy and Sell Stock with Cooldown

Java

题解

Medium

189

316. Remove Duplicate Letters

Java

题解

Hard

190

322. Coin Change

Java

题解

Medium

191

324. Wiggle Sort II

Java

题解

Medium

192

326. Power of Three

Java

题解

Easy

193

328. Odd Even Linked List

Java

题解

Medium

194

334. Increasing Triplet Subsequence

Java

题解

Medium

195

337. House Robber III

Java

题解

Medium

196

338. Counting Bits

Java

题解

Medium

197

341. Flatten Nested List Iterator

Java

题解

Medium

198

343. Integer Break

Java

题解

Medium

199

344. Reverse String

Java

题解

Easy

200

347. Top K Frequent Elements

Java

题解

Medium

201

350. Intersection of Two Arrays II

Java

题解

Easy

202

370. Range Addition

Java

题解

Medium

Plus专题

203

371. Sum of Two Integers

Java

题解

Easy

204

378. Kth Smallest Element in a Sorted Matrix

Java

题解

Medium

205

380. Insert Delete GetRandom O(1)

Java

题解

Medium

206

384. Shuffle an Array

Java

题解

Medium

207

387. First Unique Character in a String

Java

题解

Easy

208

392. Is Subsequence

Java

题解

Easy

209

394. Decode String

Java

题解

Medium

210

395. Longest Substring with At Least K Repeating Characters

Java

题解

Medium

211

400. Nth Digit

Java

题解

Medium

212

402. Remove K Digits

Java

题解

Medium

213

404. Sum of Left Leaves

Java

题解

Easy

214

406. Queue Reconstruction by Height

Java

题解

Medium

215

409. Longest Palindrome

Java

题解

Easy

216

412. Fizz Buzz

Java

题解

Easy

217

415. Add Strings

Java

题解

Easy

218

416. Partition Equal Subset Sum

Java

题解

Medium

219

429. N-ary Tree Level Order Traversal

Java

题解

Medium

广度优先

220

437. Path Sum III

Java

题解

Medium

前缀和解法还需要多思考!

221

438. Find All Anagrams in a String

Java

题解

Medium

222

448. Find All Numbers Disappeared in an Array

Java

题解

Easy

223

450. Delete Node in a BST

Java

题解

Medium

224

453. Minimum Moves to Equal Array Elements

Java

题解

Medium

225

454. 4Sum II

Java

题解

Medium

226

462. Minimum Moves to Equal Array Elements II

Java

题解

Medium

快速选择

227

474. Ones and Zeroes

Java

题解

Medium

228

480. Sliding Window Median

Java

题解

Hard

229

494. Target Sum

Java

题解

Medium

230

496. Next Greater Element I

Java

题解

Easy

231

501. Find Mode in Binary Search Tree

Java

题解

Easy

232

503. Next Greater Element II

Java

题解

Medium

233

509. Fibonacci Number

Java

题解

Easy

234

513. Find Bottom Left Tree Value

Java

题解

Medium

235

515. Find Largest Value in Each Tree Row

Java

题解

Medium

层序遍历

236

523. Continuous Subarray Sum

Java

题解

Medium

前缀和

237

528. Random Pick with Weight

Java

题解

Medium

238

530. Minimum Absolute Difference in BST

Java

题解

Easy

239

538. Convert BST to Greater Tree

Java

题解

Easy

240

543. Diameter of Binary Tree

Java

题解

Easy

241

559. Maximum Depth of N-ary Tree

Java

题解

Easy

242

560. Subarray Sum Equals K

Java

题解

Medium

前缀和

243

567. Permutation in String

Java

题解

Medium

244

581. Shortest Unsorted Continuous Subarray

Java

题解

Easy

245

617. Merge Two Binary Trees

Java

题解

Easy

246

621. Task Scheduler

Java

题解

Medium

247

637. Average of Levels in Binary Tree

Java

题解

Easy

248

647. Palindromic Substrings

Java

题解

Medium

249

654. Maximum Binary Tree

Java

题解

Medium

250

669. Trim a Binary Search Tree

Java

题解

Easy

251

695. Max Area of Island

Java

题解

Medium

252

698. Partition to K Equal Sum Subsets

Java

题解

Medium

253

700. Search in a Binary Search Tree

Java

题解

Easy

254

701. Insert into a Binary Search Tree

Java

题解

Medium

255

704. Binary Search

Java

题解

Easy

256

710. Random Pick with Blacklist

Java

题解

Hard

257

713. Subarray Product Less Than K

Java

题解

Medium

滑动窗口

258

714. Best Time to Buy and Sell Stock with Transaction Fee

Java

题解

Medium

259

718. Maximum Length of Repeated Subarray

Java

题解

Medium

260

724. Find Pivot Index

Java

题解

Easy

261

739. Daily Temperatures

Java

题解

Medium

262

744. Find Smallest Letter Greater Than Target

Java

题解

Easy

263

746. Min Cost Climbing Stairs

Java

题解

Easy

264

752. Open the Lock

Java

题解

Medium

265

768. Max Chunks To Make Sorted II

Java

题解

Hard

266

796. Rotate String

Java

题解

Easy

267

869. Reordered Power of 2

Java

题解

Medium

268

870. Advantage Shuffle

Java

题解

Medium

269

875. Koko Eating Bananas

Java

题解

Medium

二分查找

270

876. Middle of the Linked List

Java

题解

Easy

271

881. Boats to Save People

Java

题解

Medium

272

892. Surface Area of 3D Shapes

Java

题解

Easy

273

904. Fruit Into Baskets

Java

题解

Medium

274

912. Sort an Array

Java

题解

Medium

归并,快排

275

926. Flip String to Monotone Increasing

Java

题解

Medium

276

931. Minimum Falling Path Sum

Java

题解

Medium

277

946. Validate Stack Sequences

Java

题解

Medium

278

992. Subarrays with K Different Integers

Java

题解

Hard

279

1011. Capacity To Ship Packages Within D Days

Java

题解

Medium

280

1041. Robot Bounded In Circle

Java

题解

Medium

281

1090. Largest Values From Labels

Java

题解

Medium

排序规则跟 179、870 题类似:保存下标,使用其他数组的值对下标数组进行排序。

282

1094. Car Pooling

Java

题解

Medium

283

1109. Corporate Flight Bookings

Java

题解

Medium

284

1110. Delete Nodes And Return Forest

Java

题解

Medium

285

1253. Reconstruct a 2-Row Binary Matrix

Java

题解

Medium

286

1480. Running Sum of 1d Array

Java

题解

Easy

287

1644. Lowest Common Ancestor of a Binary Tree II

Java

题解

Medium

树形DP套路,没有验证答案!

288

1650. Lowest Common Ancestor of a Binary Tree III

Java

题解

Medium

链表相交

289

1823. Find the Winner of the Circular Game

Java

题解

Medium

290

1864. Minimum Number of Swaps to Make the Binary String Alternating

Java

题解

Medium

291

1905. Count Sub Islands

Java

题解

Medium