Skip to content

diguage/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

25. Reverse Nodes in k-Group

Java

题解

Hard

25

26. Remove Duplicates from Sorted Array

Java

题解

Easy

26

27. Remove Element

Java

题解

Easy

27

28. Implement strStr()

Java

题解

Easy

28

29. Divide Two Integers

Java

题解

Medium

29

31. Next Permutation

Java

题解

Medium

30

33. Search in Rotated Sorted Array

Java

题解

Medium

31

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

Java

题解

Medium

32

35. Search Insert Position

Java

题解

Easy

33

36. Valid Sudoku

Java

题解

Medium

34

37. Sudoku Solver

Java

题解

Hard

35

38. Count and Say

Java

题解

Easy

36

39. Combination Sum

Java

题解

Medium

37

40. Combination Sum II

Java

题解

Medium

38

41. First Missing Positive

Java

题解

Hard

39

42. Trapping Rain Water

Java

题解

Hard

单调栈

40

43. Multiply Strings

Java

题解

Medium

41

45. Jump Game II

Java

题解

Hard

42

46. Permutations

Java

题解

Medium

43

47. Permutations II

Java

题解

Medium

44

48. Rotate Image

Java

题解

Medium

45

49. Group Anagrams

Java

题解

Medium

46

50. Pow(x, n)

Java

题解

Medium

47

51. N-Queens

Java

题解

Hard

48

52. N-Queens II

Java

题解

Hard

49

53. Maximum Subarray

Java

题解

Easy

50

54. Spiral Matrix

Java

题解

Medium

51

55. Jump Game

Java

题解

Medium

52

56. Merge Intervals

Java

题解

Medium

53

57. Insert Interval

Java

题解

Hard

54

58. Length of Last Word

Java

题解

Easy

55

59. Spiral Matrix II

Java

题解

Medium

56

60. Permutation Sequence

Java

题解

Medium

57

61. Rotate List

Java

题解

Medium

58

62. Unique Paths

Java

题解

Medium

59

63. Unique Paths II

Java

题解

Medium

60

64. Minimum Path Sum

Java

题解

Medium

61

66. Plus One

Java

题解

Easy

62

67. Add Binary

Java

题解

Easy

63

69. Sqrt(x)

Java

题解

Easy

64

70. Climbing Stairs

Java

题解

Easy

65

71. Simplify Path

Java

题解

Medium

66

72. Edit Distance

Java

题解

Hard

67

73. Set Matrix Zeroes

Java

题解

Medium

68

75. Sort Colors

Java

题解

Medium

69

76. Minimum Window Substring

Java

题解

Hard

70

77. Combinations

Java

题解

Medium

71

78. Subsets

Java

题解

Medium

72

79. Word Search

Java

题解

Medium

73

80. Remove Duplicates from Sorted Array II

Java

题解

Medium

74

81. Search in Rotated Sorted Array II

Java

题解

Medium

75

82. Remove Duplicates from Sorted List II

Java

题解

Medium

76

83. Remove Duplicates from Sorted List

Java

题解

Easy

77

86. Partition List

Java

题解

Medium

78

88. Merge Sorted Array

Java

题解

Easy

79

89. Gray Code

Java

题解

Medium

80

90. Subsets II

Java

题解

Medium

81

91. Decode Ways

Java

题解

Medium

82

92. Reverse Linked List II

Java

题解

Medium

83

93. Restore IP Addresses

Java

题解

Medium

84

94. Binary Tree Inorder Traversal

Java

题解

Medium

85

95. Unique Binary Search Trees II

Java

题解

Medium

86

96. Unique Binary Search Trees

Java

题解

Medium

87

98. Validate Binary Search Tree

Java

题解

Medium

树形DP套路或中序遍历

88

99. Recover Binary Search Tree

Java

题解

Medium

Morris遍历

89

100. Same Tree

Java

题解

Easy

90

101. Symmetric Tree

Java

题解

Easy

91

102. Binary Tree Level Order Traversal

Java

题解

Medium

92

103. Binary Tree Zigzag Level Order Traversal

Java

题解

Medium

93

104. Maximum Depth of Binary Tree

Java

题解

Easy

94

105. Construct Binary Tree from Preorder and Inorder Traversal

Java

题解

Medium

迭代如何实现?

95

106. Construct Binary Tree from Inorder and Postorder Traversal

Java

题解

Medium

迭代如何实现?

96

107. Binary Tree Level Order Traversal II

Java

题解

Easy

97

108. Convert Sorted Array to Binary Search Tree

Java

题解

Easy

98

109. Convert Sorted List to Binary Search Tree

Java

题解

Medium

分治+中序遍历

99

110. Balanced Binary Tree

Java

题解

Easy

100

111. Minimum Depth of Binary Tree

Java

题解

Easy

Morris解法需要深入研究

101

112. Path Sum

Java

题解

Easy

102

113. Path Sum II

Java

题解

Medium

103

114. Flatten Binary Tree to Linked List

Java

题解

Medium

104

116. Populating Next Right Pointers in Each Node

Java

题解

Medium

105

117. Populating Next Right Pointers in Each Node II

Java

题解

Medium

106

118. Pascal’s Triangle

Java

题解

Easy

107

119. Pascal’s Triangle II

Java

题解

Easy

108

120. Triangle

Java

题解

Medium

109

121. Best Time to Buy and Sell Stock

Java

题解

Easy

110

122. Best Time to Buy and Sell Stock II

Java

题解

Easy

111

123. Best Time to Buy and Sell Stock III

Java

题解

Hard

112

124. Binary Tree Maximum Path Sum

Java

题解

Hard

113

125. Valid Palindrome

Java

题解

Easy

114

127. Word Ladder

Java

题解

Medium

115

129. Sum Root to Leaf Numbers

Java

题解

Medium

116

130. Surrounded Regions

Java

题解

Medium

117

131. Palindrome Partitioning

Java

题解

Medium

118

133. Clone Graph

Java

题解

Medium

119

134. Gas Station

Java

题解

Medium

120

135. Candy

Java

题解

Hard

121

136. Single Number

Java

题解

Easy

122

137. Single Number II

Java

题解

Medium

123

138. Copy List with Random Pointer

Java

题解

Medium

124

139. Word Break

Java

题解

Medium

125

141. Linked List Cycle

Java

题解

Easy

126

142. Linked List Cycle II

Java

题解

Medium

127

144. Binary Tree Preorder Traversal

Java

题解

Medium

128

145. Binary Tree Postorder Traversal

Java

题解

Easy

强化迭代

129

146. LRU Cache

Java

题解

Medium

130

148. Sort List

Java

题解

Medium

131

150. Evaluate Reverse Polish Notation

Java

题解

Medium

132

151. Reverse Words in a String

Java

题解

Medium

133

152. Maximum Product Subarray

Java

题解

Medium

134

153. Find Minimum in Rotated Sorted Array

Java

题解

Medium

135

154. Find Minimum in Rotated Sorted Array II

Java

题解

Hard

136

155. Min Stack

Java

题解

Easy

137

160. Intersection of Two Linked Lists

Java

题解

Easy

138

162. Find Peak Element

Java

题解

Medium

139

166. Fraction to Recurring Decimal

Java

题解

Medium

140

167. Two Sum II - Input array is sorted

Java

题解

Easy

141

169. Majority Element

Java

题解

Easy

142

171. Excel Sheet Column Number

Java

题解

Easy

143

172. Factorial Trailing Zeroes

Java

题解

Easy

144

175. Combine Two Tables

SQL

题解

Easy

145

176. Second Highest Salary

SQL

题解

Easy

146

179. Largest Number

Java

题解

Medium

147

188. Best Time to Buy and Sell Stock IV

Java

题解

Hard

148

189. Rotate Array

Java

题解

Easy

149

190. Reverse Bits

Java

题解

Easy

150

191. Number of 1 Bits

Java

题解

Easy

151

198. House Robber

Java

题解

Easy

152

199. Binary Tree Right Side View

Java

题解

Medium

递归+DFS解法有意思

153

200. Number of Islands

Java

题解

Medium

154

202. Happy Number

Java

题解

Easy

155

204. Count Primes

Java

题解

Easy

156

205. Isomorphic Strings

Java

题解

Easy

157

206. Reverse Linked List

Java

题解

Easy

158

207. Course Schedule

Java

题解

Medium

159

208. Implement Trie (Prefix Tree)

Java

题解

Medium

160

210. Course Schedule II

Java

题解

Medium

161

215. Kth Largest Element in an Array

Java

题解

Medium

162

217. Contains Duplicate

Java

题解

Easy

163

221. Maximal Square

Java

题解

Medium

164

222. Count Complete Tree Nodes

Java

题解

Medium

165

226. Invert Binary Tree

Java

题解

Easy

166

227. Basic Calculator II

Java

题解

Medium

167

230. Kth Smallest Element in a BST

Java

题解

Medium

168

231. Power of Two

Java

题解

Easy

169

232. Implement Queue using Stacks

Java

题解

Easy

170

234. Palindrome Linked List

Java

题解

Easy

171

235. Lowest Common Ancestor of a Binary Search Tree

Java

题解

Easy

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

172

236. Lowest Common Ancestor of a Binary Tree

Java

题解

Medium

173

237. Delete Node in a Linked List

Java

题解

Easy

174

238. Product of Array Except Self

Java

题解

Medium

175

239. Sliding Window Maximum

Java

题解

Hard

176

240. Search a 2D Matrix II

Java

题解

Medium

177

242. Valid Anagram

Java

题解

Easy

178

257. Binary Tree Paths

Java

题解

Easy

179

268. Missing Number

Java

题解

Easy

180

278. First Bad Version

Java

题解

Easy

181

279. Perfect Squares

Java

题解

Medium

182

283. Move Zeroes

Java

题解

Easy

183

287. Find the Duplicate Number

Java

题解

Medium

184

289. Game of Life

Java

题解

Medium

185

295. Find Median from Data Stream

Java

题解

Hard

186

297. Serialize and Deserialize Binary Tree

Java

题解

Hard

注意思维误区!

187

300. Longest Increasing Subsequence

Java

题解

Medium

188

303. Range Sum Query - Immutable

Java

题解

Easy

189

304. Range Sum Query 2D - Immutable

Java

题解

Medium

190

309. Best Time to Buy and Sell Stock with Cooldown

Java

题解

Medium

191

316. Remove Duplicate Letters

Java

题解

Hard

192

322. Coin Change

Java

题解

Medium

193

324. Wiggle Sort II

Java

题解

Medium

194

326. Power of Three

Java

题解

Easy

195

328. Odd Even Linked List

Java

题解

Medium

196

334. Increasing Triplet Subsequence

Java

题解

Medium

197

337. House Robber III

Java

题解

Medium

198

338. Counting Bits

Java

题解

Medium

199

341. Flatten Nested List Iterator

Java

题解

Medium

200

343. Integer Break

Java

题解

Medium

201

344. Reverse String

Java

题解

Easy

202

347. Top K Frequent Elements

Java

题解

Medium

203

350. Intersection of Two Arrays II

Java

题解

Easy

204

370. Range Addition

Java

题解

Medium

Plus专题

205

371. Sum of Two Integers

Java

题解

Easy

206

378. Kth Smallest Element in a Sorted Matrix

Java

题解

Medium

207

380. Insert Delete GetRandom O(1)

Java

题解

Medium

208

384. Shuffle an Array

Java

题解

Medium

209

387. First Unique Character in a String

Java

题解

Easy

210

392. Is Subsequence

Java

题解

Easy

211

394. Decode String

Java

题解

Medium

212

395. Longest Substring with At Least K Repeating Characters

Java

题解

Medium

213

400. Nth Digit

Java

题解

Medium

214

402. Remove K Digits

Java

题解

Medium

215

404. Sum of Left Leaves

Java

题解

Easy

216

406. Queue Reconstruction by Height

Java

题解

Medium

217

409. Longest Palindrome

Java

题解

Easy

218

412. Fizz Buzz

Java

题解

Easy

219

415. Add Strings

Java

题解

Easy

220

416. Partition Equal Subset Sum

Java

题解

Medium

221

429. N-ary Tree Level Order Traversal

Java

题解

Medium

广度优先

222

437. Path Sum III

Java

题解

Medium

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

223

438. Find All Anagrams in a String

Java

题解

Medium

224

448. Find All Numbers Disappeared in an Array

Java

题解

Easy

225

450. Delete Node in a BST

Java

题解

Medium

226

453. Minimum Moves to Equal Array Elements

Java

题解

Medium

227

454. 4Sum II

Java

题解

Medium

228

462. Minimum Moves to Equal Array Elements II

Java

题解

Medium

快速选择

229

474. Ones and Zeroes

Java

题解

Medium

230

480. Sliding Window Median

Java

题解

Hard

231

494. Target Sum

Java

题解

Medium

232

496. Next Greater Element I

Java

题解

Easy

233

501. Find Mode in Binary Search Tree

Java

题解

Easy

234

503. Next Greater Element II

Java

题解

Medium

235

509. Fibonacci Number

Java

题解

Easy

236

513. Find Bottom Left Tree Value

Java

题解

Medium

237

515. Find Largest Value in Each Tree Row

Java

题解

Medium

层序遍历

238

523. Continuous Subarray Sum

Java

题解

Medium

前缀和

239

528. Random Pick with Weight

Java

题解

Medium

240

530. Minimum Absolute Difference in BST

Java

题解

Easy

241

538. Convert BST to Greater Tree

Java

题解

Easy

242

543. Diameter of Binary Tree

Java

题解

Easy

243

547. 省份数量

Java

题解

Medium

244

559. Maximum Depth of N-ary Tree

Java

题解

Easy

245

560. Subarray Sum Equals K

Java

题解

Medium

前缀和

246

567. Permutation in String

Java

题解

Medium

247

581. Shortest Unsorted Continuous Subarray

Java

题解

Easy

248

617. Merge Two Binary Trees

Java

题解

Easy

249

621. Task Scheduler

Java

题解

Medium

250

637. Average of Levels in Binary Tree

Java

题解

Easy

251

647. Palindromic Substrings

Java

题解

Medium

252

654. Maximum Binary Tree

Java

题解

Medium

253

669. Trim a Binary Search Tree

Java

题解

Easy

254

695. Max Area of Island

Java

题解

Medium

255

698. Partition to K Equal Sum Subsets

Java

题解

Medium

256

700. Search in a Binary Search Tree

Java

题解

Easy

257

701. Insert into a Binary Search Tree

Java

题解

Medium

258

704. Binary Search

Java

题解

Easy

259

710. Random Pick with Blacklist

Java

题解

Hard

260

713. Subarray Product Less Than K

Java

题解

Medium

滑动窗口

261

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

Java

题解

Medium

262

718. Maximum Length of Repeated Subarray

Java

题解

Medium

263

724. Find Pivot Index

Java

题解

Easy

264

739. Daily Temperatures

Java

题解

Medium

265

744. Find Smallest Letter Greater Than Target

Java

题解

Easy

266

746. Min Cost Climbing Stairs

Java

题解

Easy

267

752. Open the Lock

Java

题解

Medium

268

768. Max Chunks To Make Sorted II

Java

题解

Hard

269

796. Rotate String

Java

题解

Easy

270

869. Reordered Power of 2

Java

题解

Medium

271

870. Advantage Shuffle

Java

题解

Medium

272

875. Koko Eating Bananas

Java

题解

Medium

二分查找

273

876. Middle of the Linked List

Java

题解

Easy

274

881. Boats to Save People

Java

题解

Medium

275

892. Surface Area of 3D Shapes

Java

题解

Easy

276

904. Fruit Into Baskets

Java

题解

Medium

277

912. Sort an Array

Java

题解

Medium

归并,快排

278

926. Flip String to Monotone Increasing

Java

题解

Medium

279

931. Minimum Falling Path Sum

Java

题解

Medium

280

946. Validate Stack Sequences

Java

题解

Medium

281

992. Subarrays with K Different Integers

Java

题解

Hard

282

1011. Capacity To Ship Packages Within D Days

Java

题解

Medium

283

1041. Robot Bounded In Circle

Java

题解

Medium

284

1090. Largest Values From Labels

Java

题解

Medium

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

285

1094. Car Pooling

Java

题解

Medium

286

1109. Corporate Flight Bookings

Java

题解

Medium

287

1110. Delete Nodes And Return Forest

Java

题解

Medium

288

1253. Reconstruct a 2-Row Binary Matrix

Java

题解

Medium

289

1480. Running Sum of 1d Array

Java

题解

Easy

290

1644. Lowest Common Ancestor of a Binary Tree II

Java

题解

Medium

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

291

1650. Lowest Common Ancestor of a Binary Tree III

Java

题解

Medium

链表相交

292

1823. Find the Winner of the Circular Game

Java

题解

Medium

293

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

Java

题解

Medium

294

1905. Count Sub Islands

Java

题解

Medium

295

2507. Smallest Value After Replacing With Sum of Prime Factors

Java

题解

Medium

截止目前,一共完成 295 道题。