数组
- 283 MoveZeros
- 27 Remove Element
- 26 Remove Duplicated from Sorted Array
- 80 Remove Duplicated from Sorted Array 2
- 75 Sort Colors
- 88 Merge Sorted Array
- 215 Kth Largest Element in an Array
双索引技术
(对撞指针)
- 167 Two Sum 2 - Input array is sorted
- 125 Valid Palindrome
- 344 Reverse String
- 345 Reverse Vowels of a String
- 11 Container With Most Water
(滑动窗口)
- 209 Minimum Size Subarray Sum
- 3 Longest SubString Without Repeating Characters
- 438 Find All Anagrams in a String
- 76 Minimum Window Substring
查找表
- 349 Intersection of Two Arrays
- 350 Intersection of Two Arrays
- 242 Valid Anagram
- 202 Happy Number
- 290 Word Pattern
- 205 Isomorphic Strings
- 451 Sort Characters By Frequency
- 1 Two Sum(先排序,再用对撞指针,nlogn)(查找表)
- 15 3Sum
- 18 4Sum
- 16 3Sum Closest(不一定适用查找表)
- 454 4Sum 2
- 49 Group Anagrams
- 447 Number of Boomerangs(整形越界的小陷阱,浮点误差)
- 148 Max Points on a Line
(滑动窗口+查找表)
- 219 Container Duplicate 2
- 217 Container Duplicate
- 220 Container Duplicate 3(tree set)
链表
206 Reverse Linked List
92 Reverse Linked List 2
83 Remove Duplicates from Sorted List
86 Partitions List
328 Odd Even Linked List
2 Add Two Numbers(负数?)
445 Add Two Numbers2
(虚拟头结点)
- 203 Remove Linked List Element
- 82 Remove Duplicated from Sorted List 2
- 21 Merge Two Sorted Lists
- 24 Swap Nodes in Paris
- 25 Reverse Nodes in k-Group
- 147 Insertion Sort List
- 148 Sort List
(不仅仅是穿针引线)
- 237 Delete Node in a Linked List
(链表和双指针)
- 19 Remove Nth Node From End of List
- 61 Rotate List
- 143 Reorder List
- 234 Palindrome Linked List
栈
- 20 Valid Parentheses
- 150 Evaluate Reverse Polish Notation
- 71 Simiplify Path
(栈和递归的紧密关系)
- 144 Binary Tree Preorder Traversal(用stack模拟系统栈实现非递归遍历)
- 94 Binary Tree Inorder Traversal
- 145 Binary Tree Postorder Traversal
- 341 Flatten Nested List Iterator
队列
队列的基本应用:广度优先遍历
- 树;层序遍历
- 图; 无权图的最短路径
(层序遍历)
- 102 Binary Tree Level Order Traversal
- 107 Binary Tree Level Order Traversal2
- 103 Binary Tree Zigzag Level Order Traversal
- 199 Binary Tree Right Side View
(BFS和图的最短路径)
- 279 Perfect Squares(贪心算法不成立,转化为图或树)
- 127 Word Ladder
- 126 Word Ladder 2
优先队列(堆,白板编程)
- 347 Top K Frequent Element(nlogk, nlog(n-k))
- 23 Merge K Sorted Lists
二叉树和递归
- 104 Maximum Depth of Binary Tree
- 111 Minimum Depth of Binary Tree
- 226 Invert Binary Tree
- 100 Same Tree
- 101 Symmetric Tree
- 222 Count Complete Tree Nodes
- 110 Balanced Binary Tree
(递归终止条件)
- 112 Path Sum
- 111 Minimum Depth of Binary Tree
- 404 Sum of Left Leaves
(使用递归函数的返回值)
- 257 Binary Tree Paths
- 113 Path Sum2
- 129 Sum Root to Leaf Numbers
- 437 Path Sum3
(BST)
- 235 Lowest Common Ancestor of a Binary Search Tree
- 98 Validate Binary Search Tree
- 450 Delete Node in a BST
- 108 Convert Sorted Array to BST
- 230 Kth Smallest Element in a BST
- 236 Lowest Common Ancestor of a Binary Tree(LCA)
递归和回溯(树形问题)
- 17 Letter Combination of a Phone Number(O(2^N))
- 93 Restore IP Address
- 131 Palindrome Partitioning
(排列问题)
- 46 Permutations (Perms(nums[0…n-1])={取出一个数字}+ Perms(nums[{0..n-1}-这个数字]))
- 47 Permutations2
(组合问题)
- 77 Combinations(剪枝)
- 39 Combination Sum
- 40 Combination Sum2
- 216 Combination Sum3
- 78 Subsets
- 90 Subsets2
- 401 Binary Watch
(二维平面上使用回溯法)
- 79 Word Search (偏移量)
- 200 Number of Islands(floodfill, DFS)
- 130 Surrounded Regions
- 417 Pacific Atlantic Water Flow
- 51 N-Queens
- 52 N-Queens2
- 37 Sudoku Solver
动态规划
重叠子问题
记忆化搜索(递归的基础上添加记忆化过程)- 自上向下的解决问题
动态规划 - 自下向上的解决问题
- 70 Climbing Stairs
- 120 Triangle
- 64 Minimum Path Sum(条件)
最优子结构
- 343 Integer Break(暴力2^N,不知道几重循环,用递归,组合的解空间)
1 279 Perfect Squares- 91 Decode Ways
- 62 Unique Paths
- 63 Unique Paths2
(状态和状态转移)
- 198 House Robber(暴力2^n)(状态和状态转移,两种状态定义)
- 213 House Robber2
- 337 House Robber3
- 309 Best Time to Buy and Sell Stock with Cooldown
(0-1 背包)暴力2^N
- 416 Partition Equal Subset Sum
- 322 Coin Change
- 377 Combination Sum4
- 474 Ones and Zeroes
- 139 Word Break
- 494 Target Sum
(LIS)
- 300 Longest Increasing Subsequence(n^2动态规划,有nlgn)
- 376 Wiggle Subsequence
- (最长公共子序列)
- (dijkstra)
- (所有最长上升子序列是什么)
- (0-1背包存放的是什么)
贪心算法(排序)
- 455 Assign Cookies
- 392 Is Subsequence
(贪心算法和动态规划)
- 435 Non-overlapping Intervals
贪心选择性质
问题的整体最优解可以通过一系列局部最优的选择,即贪心选择来达到。
- (最小生成树,最短路径)