0%

Leetcode题选

数组

  1. 283 MoveZeros
  2. 27 Remove Element
  3. 26 Remove Duplicated from Sorted Array
  4. 80 Remove Duplicated from Sorted Array 2
  5. 75 Sort Colors
  6. 88 Merge Sorted Array
  7. 215 Kth Largest Element in an Array

双索引技术

(对撞指针)

  1. 167 Two Sum 2 - Input array is sorted
  2. 125 Valid Palindrome
  3. 344 Reverse String
  4. 345 Reverse Vowels of a String
  5. 11 Container With Most Water

(滑动窗口)

  1. 209 Minimum Size Subarray Sum
  2. 3 Longest SubString Without Repeating Characters
  3. 438 Find All Anagrams in a String
  4. 76 Minimum Window Substring

数组题思维导图小结,请用ithoughts打开.对应代码

查找表

  1. 349 Intersection of Two Arrays
  2. 350 Intersection of Two Arrays
  3. 242 Valid Anagram
  4. 202 Happy Number
  5. 290 Word Pattern
  6. 205 Isomorphic Strings
  7. 451 Sort Characters By Frequency
  1. 1 Two Sum(先排序,再用对撞指针,nlogn)(查找表)
  2. 15 3Sum
  3. 18 4Sum
  4. 16 3Sum Closest(不一定适用查找表)
  5. 454 4Sum 2
  6. 49 Group Anagrams
  7. 447 Number of Boomerangs(整形越界的小陷阱,浮点误差)
  8. 148 Max Points on a Line

(滑动窗口+查找表)

  1. 219 Container Duplicate 2
  2. 217 Container Duplicate
  3. 220 Container Duplicate 3(tree set)

链表

  1. 206 Reverse Linked List

  2. 92 Reverse Linked List 2

  3. 83 Remove Duplicates from Sorted List

  4. 86 Partitions List

  5. 328 Odd Even Linked List

  6. 2 Add Two Numbers(负数?)

  7. 445 Add Two Numbers2

(虚拟头结点)

  1. 203 Remove Linked List Element
  2. 82 Remove Duplicated from Sorted List 2
  3. 21 Merge Two Sorted Lists
  4. 24 Swap Nodes in Paris
  5. 25 Reverse Nodes in k-Group
  6. 147 Insertion Sort List
  7. 148 Sort List

(不仅仅是穿针引线)

  1. 237 Delete Node in a Linked List

(链表和双指针)

  1. 19 Remove Nth Node From End of List
  2. 61 Rotate List
  3. 143 Reorder List
  4. 234 Palindrome Linked List

  1. 20 Valid Parentheses
  2. 150 Evaluate Reverse Polish Notation
  3. 71 Simiplify Path

(栈和递归的紧密关系)

  1. 144 Binary Tree Preorder Traversal(用stack模拟系统栈实现非递归遍历)
  2. 94 Binary Tree Inorder Traversal
  3. 145 Binary Tree Postorder Traversal
  4. 341 Flatten Nested List Iterator

队列

队列的基本应用:广度优先遍历

  • 树;层序遍历
  • 图; 无权图的最短路径

(层序遍历)

  1. 102 Binary Tree Level Order Traversal
  2. 107 Binary Tree Level Order Traversal2
  3. 103 Binary Tree Zigzag Level Order Traversal
  4. 199 Binary Tree Right Side View

(BFS和图的最短路径)

  1. 279 Perfect Squares(贪心算法不成立,转化为图或树)
  2. 127 Word Ladder
  3. 126 Word Ladder 2

优先队列(堆,白板编程)

  1. 347 Top K Frequent Element(nlogk, nlog(n-k))
  2. 23 Merge K Sorted Lists

二叉树和递归

  1. 104 Maximum Depth of Binary Tree
  2. 111 Minimum Depth of Binary Tree
  3. 226 Invert Binary Tree
  4. 100 Same Tree
  5. 101 Symmetric Tree
  6. 222 Count Complete Tree Nodes
  7. 110 Balanced Binary Tree

(递归终止条件)

  1. 112 Path Sum
  2. 111 Minimum Depth of Binary Tree
  3. 404 Sum of Left Leaves

(使用递归函数的返回值)

  1. 257 Binary Tree Paths
  2. 113 Path Sum2
  3. 129 Sum Root to Leaf Numbers
  4. 437 Path Sum3

(BST)

  1. 235 Lowest Common Ancestor of a Binary Search Tree
  2. 98 Validate Binary Search Tree
  3. 450 Delete Node in a BST
  4. 108 Convert Sorted Array to BST
  5. 230 Kth Smallest Element in a BST
  6. 236 Lowest Common Ancestor of a Binary Tree(LCA)

递归和回溯(树形问题)

  1. 17 Letter Combination of a Phone Number(O(2^N))
  2. 93 Restore IP Address
  3. 131 Palindrome Partitioning

(排列问题)

  1. 46 Permutations (Perms(nums[0…n-1])={取出一个数字}+ Perms(nums[{0..n-1}-这个数字]))
  2. 47 Permutations2

(组合问题)

  1. 77 Combinations(剪枝)
  2. 39 Combination Sum
  3. 40 Combination Sum2
  4. 216 Combination Sum3
  5. 78 Subsets
  6. 90 Subsets2
  7. 401 Binary Watch

(二维平面上使用回溯法)

  1. 79 Word Search (偏移量)
  2. 200 Number of Islands(floodfill, DFS)
  3. 130 Surrounded Regions
  4. 417 Pacific Atlantic Water Flow
  5. 51 N-Queens
  6. 52 N-Queens2
  7. 37 Sudoku Solver

动态规划

重叠子问题
记忆化搜索(递归的基础上添加记忆化过程)- 自上向下的解决问题
动态规划 - 自下向上的解决问题

  1. 70 Climbing Stairs
  2. 120 Triangle
  3. 64 Minimum Path Sum(条件)

最优子结构

  1. 343 Integer Break(暴力2^N,不知道几重循环,用递归,组合的解空间)
    1 279 Perfect Squares
  2. 91 Decode Ways
  3. 62 Unique Paths
  4. 63 Unique Paths2

(状态和状态转移)

  1. 198 House Robber(暴力2^n)(状态和状态转移,两种状态定义)
  2. 213 House Robber2
  3. 337 House Robber3
  4. 309 Best Time to Buy and Sell Stock with Cooldown

(0-1 背包)暴力2^N

  1. 416 Partition Equal Subset Sum
  2. 322 Coin Change
  3. 377 Combination Sum4
  4. 474 Ones and Zeroes
  5. 139 Word Break
  6. 494 Target Sum

(LIS)

  1. 300 Longest Increasing Subsequence(n^2动态规划,有nlgn)
  2. 376 Wiggle Subsequence
  • (最长公共子序列)
  • (dijkstra)
  • (所有最长上升子序列是什么)
  • (0-1背包存放的是什么)

贪心算法(排序)

  1. 455 Assign Cookies
  2. 392 Is Subsequence

(贪心算法和动态规划)

  1. 435 Non-overlapping Intervals

贪心选择性质
问题的整体最优解可以通过一系列局部最优的选择,即贪心选择来达到。

  • (最小生成树,最短路径)

欢迎加好友
  • 作者: wang yang
  • 版权: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处!