LeetCode Problems
为方便以后回顾,先列出所有的150道题:
- Two Sum
- Add Two Numbers
- Longest Substring Without Repeating Characters
- Median of Two Sorted Arrays
- Longest Palindromic Substring
- Reverse Integer
- Regular Expression Matching
- Container With Most Water
- 3Sum
- Letter Combinations of a Phone Number
- Remove Nth Node From End of List
- Valid Parentheses
- Merge Two Sorted Lists
- Generate Parentheses
- Merge k Sorted Lists
- Reverse Nodes in k-Group
- Search in Rotated Sorted Array
- Valid Sudoku
- Combination Sum
- Combination Sum II
- Trapping Rain Water
- Multiply Strings
- Jump Game II
- Permutations
- Rotate Image
- Group Anagrams
- Pow(x, n)
- N-Queens
- Maximum Subarray
- Spiral Matrix
- Jump Game
- Merge Intervals
- Insert Interval
- Unique Paths
- Plus One
- Climbing Stairs
- Edit Distance
- Set Matrix Zeroes
- Search a 2D Matrix
- Minimum Window Substring
- Subsets
- Word Search
- Largest Rectangle in Histogram
- Subsets II
- Decode Ways
- Interleaving String
- Validate Binary Search Tree
- Same Tree
- Binary Tree Level Order Traversal
- Maximum Depth of Binary Tree
- Construct Binary Tree from Preorder and Inorder Traversal
- Balanced Binary Tree
- Distinct Subsequences
- Best Time to Buy and Sell Stock
- Binary Tree Maximum Path Sum
- Valid Palindrome
- Word Ladder
- Longest Consecutive Sequence
- Surrounded Regions
- Palindrome Partitioning
- Clone Graph
- Gas Station
- Single Number
- Copy List with Random Pointer
- Word Break
- Linked List Cycle
- Reorder List
- LRU Cache
- Evaluate Reverse Polish Notation
- Maximum Product Subarray
- Find Minimum in Rotated Sorted Array
- Min Stack
- Two Sum II - Input Array Is Sorted
- Reverse Bits
- Number of 1 Bits
- House Robber
- Binary Tree Right Side View
- Number of Islands
- Happy Number
- Reverse Linked List
- Course Schedule
- Implement Trie (Prefix Tree)
- Course Schedule II
- Design Add and Search Words Data Structure
- Word Search II
- House Robber II
- Kth Largest Element in an Array
- Contains Duplicate
- Invert Binary Tree
- Kth Smallest Element in a BST
- Lowest Common Ancestor of a Binary Search Tree
- Product of Array Except Self
- Sliding Window Maximum
- Valid Anagram
- Meeting Rooms
- Meeting Rooms II
- Graph Valid Tree
- Missing Number
- Alien Dictionary
- Encode and Decode Strings
- Walls and Gates
- Find the Duplicate Number
- Find Median from Data Stream
- Serialize and Deserialize Binary Tree
- Longest Increasing Subsequence
- Best Time to Buy and Sell Stock with Cooldown
- Burst Balloons
- Coin Change
- Number of Connected Components in an Undirected Graph
- Longest Increasing Path in a Matrix
- Reconstruct Itinerary
- Counting Bits
- Top K Frequent Elements
- Design Twitter
- Sum of Two Integers
- Partition Equal Subset Sum
- Pacific Atlantic Water Flow
- Longest Repeating Character Replacement
- Non-overlapping Intervals
- Target Sum
- Coin Change II
- Diameter of Binary Tree
- Permutation in String
- Subtree of Another Tree
- Task Scheduler
- Palindromic Substrings
- Valid Parenthesis String
- Redundant Connection
- Max Area of Island
- Daily Temperatures
- Network Delay Time
- Min Cost Climbing Stairs
- Partition Labels
- Kth Largest Element in a Stream
- Binary Search
- Swim in Rising Water
- Cheapest Flights Within K Stops
- Hand of Straights
- Car Fleet
- Koko Eating Bananas
- K Closest Points to Origin
- Time Based Key-Value Store
- Rotting Oranges
- Last Stone Weight
- Longest Common Subsequence
- Count Good Nodes in Binary Tree
- Min Cost to Connect All Points
- Minimum Interval to Include Each Query
- Merge Triplets to Form Target Triplet
- Detect Squares
遇到数目繁多的,先做的事情是分类:
一、数组
1. 双指针/滑动窗口
- 1. Two Sum
- 3. Longest Substring Without Repeating Characters
- 16. Reverse Nodes in k-Group
- 26. Group Anagrams
- 42. Word Search
- 76. House Robber
- 93. Sliding Window Maximum
- 118. Longest Repeating Character Replacement
- 119. Non-overlapping Intervals
- 125. Task Scheduler
- 126. Palindromic Substrings
2. 排序/查找
- 4. Median of Two Sorted Arrays
- 17. Search in Rotated Sorted Array
- 33. Insert Interval
- 35. Plus One
- 74. Reverse Bits
- 87. Kth Largest Element in an Array
- 88. Contains Duplicate
- 96. Meeting Rooms II
- 102. Find the Duplicate Number
- 135. Binary Search
- 141. K Closest Points to Origin
3. 动态规划
- 5. Longest Palindromic Substring
- 31. Jump Game
- 53. Distinct Subsequences
- 58. Longest Consecutive Sequence
- 70. Maximum Product Subarray
- 105. Longest Increasing Subsequence
- 121. Coin Change II
- 126. Palindromic Substrings
- 132. Min Cost Climbing Stairs
4. 字符串操作
- 10. Letter Combinations of a Phone Number
- 22. Multiply Strings
- 43. Largest Rectangle in Histogram
- 56. Valid Palindrome
- 57. Word Ladder
- 68. LRU Cache
- 94. Valid Anagram
- 99. Alien Dictionary
- 100. Encode and Decode Strings
- 127. Valid Parenthesis String
- 139. Car Fleet
5. 其他
- 27. Pow(x, n)
- 30. Spiral Matrix
- 39. Search a 2D Matrix
- 41. Subsets
- 44. Subsets II
- 59. Surrounded Regions
- 73. Two Sum II - Input Array Is Sorted
- 78. Number of Islands
- 92. Product of Array Except Self
- 98. Missing Number
- 117. Pacific Atlantic Water Flow
- 120. Target Sum
- 129. Max Area of Island
- 136. Swim in Rising Water
二、链表
1. 快慢指针
- 19. Combination Sum
- 20. Combination Sum II
- 61. Clone Graph
- 66. Linked List Cycle
- 80. Reverse Linked List
- 142. Time Based Key-Value Store
2. 链表操作
- 2. Add Two Numbers
- 11. Remove Nth Node From End of List
- 13. Merge Two Sorted Lists
- 21. Trapping Rain Water
- 64. Copy List with Random Pointer
- 82. Implement Trie (Prefix Tree)
- 143. Rotting Oranges
三、树
1. 二叉树的遍历
- 49. Binary Tree Level Order Traversal
- 50. Maximum Depth of Binary Tree
- 77. Binary Tree Right Side View
- 90. Kth Smallest Element in a BST
- 94. Valid Anagram
- 104. Serialize and Deserialize Binary Tree
- 124. Subtree of Another Tree
2. 二叉搜索树
- 47. Validate Binary Search Tree
- 51. Construct Binary Tree from Preorder and Inorder Traversal
- 91. Lowest Common Ancestor of a Binary Search Tree
3. 其他
- 48. Same Tree
- 52. Balanced Binary Tree
- 55. Binary Tree Maximum Path Sum
- 101. Walls and Gates
- 122. Diameter of Binary Tree
- 146. Count Good Nodes in Binary Tree
四、图
- 61. Clone Graph
- 109. Number of Connected Components in an Undirected Graph
- 110. Longest Increasing Path in a Matrix
- 128. Redundant Connection
- 131. Network Delay Time
- 147. Min Cost to Connect All Points
五、其他
1. 堆/栈/队列
- 23. Jump Game II
- 72. Min Stack
- 84. Design Add and Search Words Data Structure
- 113. Top K Frequent Elements
- 134. Kth Largest Element in a Stream
- 140. Koko Eating Bananas
2. 设计
- 7. Regular Expression Matching
- 8. Container With Most Water
- 12. Valid Parentheses
- 14. Generate Parentheses
- 25. Rotate Image
- 28. N-Queens
- 32. Merge Intervals
- 34. Unique Paths
- 36. Climbing Stairs
- 37. Edit Distance
- 38. Set Matrix Zeroes
- 40. Minimum Window Substring
- 45. Decode Ways
- 46. Interleaving String
- 60. Palindrome Partitioning
- 62. Gas Station
- 63. Single Number
- 65. Word Break
- 67. Reorder List
- 69. Evaluate Reverse Polish Notation
- 71. Find Minimum in Rotated Sorted Array
- 75. Number of 1 Bits
- 79. Happy Number
- 81. Course Schedule
- 83. Course Schedule II
- 85. Word Search II
- 86. House Robber II
- 89. Invert Binary Tree
- 95. Meeting Rooms
- 97. Graph Valid Tree
- 103. Find Median from Data Stream
- 106. Best Time to Buy and Sell Stock with Cooldown
- 107. Burst Balloons
- 108. Coin Change
- 111. Reconstruct Itinerary
- 112. Counting Bits
- 114. Design Twitter
- 115. Sum of Two Integers
- 116. Partition Equal Subset Sum
- 130. Daily Temperatures
- 133. Partition Labels
- 137. Cheapest Flights Within K Stops
- 138. Hand of Straights
- 144. Last Stone Weight
- 145. Longest Common Subsequence
- 148. Minimum Interval to Include Each Query
- 149. Merge Triplets to Form Target Triplet
- 150. Detect Squares