Leetcode

1. Two Sum done

  • Description: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
  • Link
  • Solution 1: Pattern Two Pointers, Time Complexity: O(nlogn),
  • Solution 2. Use a hashtable to store

2. Add Two Numbers

  • Description: Given two non-negative integers represented by linked list in reverse order. Add the two numbers and return the sum as a linked list.
  • Link

3. Longest Substring Without Repeating Characters done

  • link
  • Solution: [[][]]

4. Median of Two Sorted Arrays

link

5. Longest Palindromic Substring

link

Description:

Solution 1: Brute force, Time Complexity: O(n^3)

Solution 2: Dynamic Programming

6. Zigzag Conversion

link

7. Reverse Integer

link

8. String to Integer (atoi)

link

9. Palindrome Number

link

10. Regular Expression Matching

link

11. Container With Most Water

link

12. Integer to Roman

link

13. Roman to Integer

link

14. Longest Common Prefix

link

15. 3Sum

link

Solution 1: Two Pointers

16. 3Sum Closest

link

17. Letter Combinations of a Phone Number

link

18. 4Sum

link

19. Remove Nth Node From End of List

link

20. Valid Parentheses

link

21. Merge Two Sorted Lists done

link

22. Generate Parentheses

link

23. Merge k Sorted Lists

link

24. Swap Nodes in Pairs

link

25. Reverse Nodes in k-Group

link

26. Remove Duplicates from Sorted Array done

link

27. Remove Element

link

28. Find the Index of the First Occurrence in a String

link

29. Divide Two Integers

link

30. Substring with Concatenation of All Words

link

31. Next Permutation

link

32. Longest Valid Parentheses

link

33. Search in Rotated Sorted Array

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

35. Search Insert Position

link

36. Valid Sudoku

link

37. Sudoku Solver

link

38. Count and Say

link

39. Combination Sum

link

40. Combination Sum II

link

41. First Missing Positive

link

42. Trapping Rain Water

link

43. Multiply Strings

link

44. Wildcard Matching

link

45. Jump Game II

link

46. Permutations

link

47. Permutations II

link

48. Rotate Image

link

49. Group Anagrams

link

50. Pow(x, n)

link

51. N-Queens

link

52. N-Queens II

link

53. Maximum Subarray

link

54. Spiral Matrix

link

55. Jump Game

link

56. Merge Intervals done

link

57. Insert Interval

link

58. Length of Last Word

link

59. Spiral Matrix II

link

60. Permutation Sequence

link

61. Rotate List

link

62. Unique Paths

link

63. Unique Paths II

link

64. Minimum Path Sum

link

  • Pattern: Dynamic Programming

65. Valid Number

link

66. Plus One

link

67. Add Binary

link

68. Text Justification

link

69. Sqrt(x)

link

70. Climbing Stairs

link

71. Simplify Path

link

72. Edit Distance

link

73. Set Matrix Zeroes

link

74. Search a 2D Matrix

link

75. Sort Colors

link

76. Minimum Window Substring

link

77. Combinations

link

78. Subsets

link

79. Word Search

link

80. Remove Duplicates from Sorted Array II

link

81. Search in Rotated Sorted Array II

link

82. Remove Duplicates from Sorted List II

link

83. Remove Duplicates from Sorted List

link

84. Largest Rectangle in Histogram

link

85. Maximal Rectangle

link

86. Partition List

link

87. Scramble String

link

88. Merge Sorted Array

link

89. Gray Code

link

90. Subsets II

link

91. Decode Ways

link

92. Reverse Linked List II

link

93. Restore IP Addresses

link

94. Binary Tree Inorder Traversal

link

95. Unique Binary Search Trees II

link

96. Unique Binary Search Trees

link

97. Interleaving String

link

98. Validate Binary Search Tree

link

99. Recover Binary Search Tree

link

100. Same Tree

link

101. Symmetric Tree

link

102. Binary Tree Level Order Traversal

link

103. Binary Tree Zigzag Level Order Traversal

link

104. Maximum Depth of Binary Tree done

link

105. Construct Binary Tree from Preorder and Inorder Traversal done

link

106. Construct Binary Tree from Inorder and Postorder Traversal

link

107. Binary Tree Level Order Traversal II

link

108. Convert Sorted Array to Binary Search Tree

link

109. Convert Sorted List to Binary Search Tree

link

110. Balanced Binary Tree done

link

111. Minimum Depth of Binary Tree

link

112. Path Sum

link

113. Path Sum II

link

114. Flatten Binary Tree to Linked List

link

115. Distinct Subsequences

116. Populating Next Right Pointers in Each Node

link

117. Populating Next Right Pointers in Each Node II

link

118. Pascal’s Triangle

link

119. Pascal’s Triangle II

link

120. Triangle

link

121. Best Time to Buy and Sell Stock

link

122. Best Time to Buy and Sell Stock II

link

123. Best Time to Buy and Sell Stock III

link

124. Binary Tree Maximum Path Sum

link

125. Valid Palindrome

link

126. Word Ladder II

link

127. Word Ladder

link

128. Longest Consecutive Sequence

link

129. Sum Root to Leaf Numbers

link

130. Surrounded Regions

link

131. Palindrome Partitioning

link

132. Palindrome Partitioning II

link

133. Clone Graph

link

134. Gas Station

link

135. Candy

link

136. Single Number done

137. Single Number II

link

138. Copy List with Random Pointer

link

139. Word Break

link

140. Word Break II

link

141. Linked List Cycle

link

142. Linked List Cycle II

link

143. Reorder List

link

144. Binary Tree Preorder Traversal

link

145. Binary Tree Postorder Traversal

link

146. LRU Cache

link

147. Insertion Sort List

link

148. Sort List

link

149. Max Points on a Line

link

150. Evaluate Reverse Polish Notation

link

151. Reverse Words in a String

link

152. Maximum Product Subarray

link

[?] 153. Find Minimum in Rotated Sorted Array

link

154. Find Minimum in Rotated Sorted Array II

link

155. Min Stack

link

156. Binary Tree Upside Down

link

157. Read N Characters Given Read4

link

158. Read N Characters Given read4 II - Call Multiple Times

link

159. Longest Substring with At Most Two Distinct Characters

link

160. Intersection of Two Linked Lists

link

161. One Edit Distance

link

162. Find Peak Element

link

163. Missing Ranges

link

164. Maximum Gap

link

165. Compare Version Numbers

link

166. Fraction to Recurring Decimal

link

167. Two Sum II - Input Array Is Sorted

link

168. Excel Sheet Column Title

link

169. Majority Element

link

170. Two Sum III - Data structure design

link

171. Excel Sheet Column Number

link

172. Factorial Trailing Zeroes

link

173. Binary Search Tree Iterator

link

174. Dungeon Game

link

175. Combine Two Tables

link

176. Second Highest Salary

link

177. Nth Highest Salary

link

178. Rank Scores

link

179. Largest Number

link

180. Consecutive Numbers

link

181. Employees Earning More Than Their Managers

link

182. Duplicate Emails

link

183. Customers Who Never Order

link

184. Department Highest Salary

link

185. Department Top Three Salaries

link

186. Reverse Words in a String II

link

187. Repeated DNA Sequences

link

188. Best Time to Buy and Sell Stock IV

link

189. Rotate Array

link

190. Reverse Bits

link

191. Number of 1 Bits

link

192. Word Frequency

link

193. Valid Phone Numbers

link

194. Transpose File

link

195. Tenth Line

link

196. Delete Duplicate Emails

link

197. Rising Temperature

link

198. House Robber

link

199. Binary Tree Right Side View

link

200. Number of Islands

link

201. Bitwise AND of Numbers Range

link

202. Happy Number

link

203. Remove Linked List Elements

link

204. Count Primes

link

205. Isomorphic Strings

link

206. Reverse Linked List

link

207. Course Schedule

link

208. Implement Trie (Prefix Tree)

link

209. Minimum Size Subarray Sum

link

Solution: Sliding Window

210. Course Schedule II

link

211. Design Add and Search Words Data Structure

link

212. Word Search II

link

213. House Robber II

link

214. Shortest Palindrome

link

215. Kth Largest Element in an Array

link

216. Combination Sum III

link

217. Contains Duplicate

link

218. The Skyline Problem

link

219. Contains Duplicate II

link

220. Contains Duplicate III

link

221. Maximal Square

link

222. Count Complete Tree Nodes

link

223. Rectangle Area

link

224. Basic Calculator

link

225. Implement Stack using Queues

link

226. Invert Binary Tree

link

227. Basic Calculator II

link

228. Summary Ranges

link

229. Majority Element II

link

230. Kth Smallest Element in a BST

link

231. Power of Two

link

232. Implement Queue using Stacks done

233. Number of Digit One

link

234. Palindrome Linked List

link

235. Lowest Common Ancestor of a Binary Search Tree

link

236. Lowest Common Ancestor of a Binary Tree

link

237. Delete Node in a Linked List

link

238. Product of Array Except Self

link

239. Sliding Window Maximum

240. Search a 2D Matrix II

link

241. Different Ways to Add Parentheses

link

242. Valid Anagram

link

243. Shortest Word Distance

link

244. Shortest Word Distance II

link

245. Shortest Word Distance III

link

246. Strobogrammatic Number

link

247. Strobogrammatic Number II

link

248. Strobogrammatic Number III

link

249. Group Shifted Strings

link

250. Count Univalue Subtrees

link

251. Flattenr2D Vector

link

252. Meeting Rooms

link

253. Meeting Rooms II

link

254. Factor Combinations

link

255. Verify Preorder Sequence in Binary Search Tree

link

256. Paint House

link

257. Binary Tree Paths

link

258. Add Digits

link

259. 3Sum Smaller

link

260. Single Number III done

261. Graph Valid Tree

link

262. Trips and Users

link

263. Ugly Number

link

264. Ugly Number II

link

265. Paint House II

link

266. Palindrome Permutation

link

267. Palindrome Permutation II

link

268. Missing Number

link

269. Alien Dictionary

link

270. Closest Binary Search Tree Value

link

271. Encode and Decode Strings

link

272. Closest Binary Search Tree Value II

link

273. Integer to English Words

link

274. H-Index

link

275. H-Index II

link

276. Paint Fence

link

277. Find the Celebrity

link

278. First Bad Version

link

279. Perfect Squares

link

280. Wiggle Sort

link

281. Zigzag Iterator

link

282. Expression Add Operators

link

283. Move Zeroes

link

284. Peeking Iterator

link

285. Inorder Successor in BST

link

286. Walls and Gates

link

287. Find the Duplicate Number

link

288. Unique Word Abbreviation

link

289. Game of Life

link

290. Word Pattern

link

291. Word Pattern II

link

292. Nim Game

link

293. Flip Game

link

294. Flip Game II

link

295. Find Median from Data Stream done

link

296. Best Meeting Point

link

297. Serialize and Deserialize Binary Tree

link

298. Binary Tree Longest Consecutive Sequence

link

299. Bulls and Cows

link

300. Longest Increasing Subsequence

link