leetcode 数据结构

本次题解包括

  • 20. Valid Parentheses
  • 146 LRU Cache
  • 150 Evaluate Reverse Polish Notation
  • 155 Min Stack
  • 187 Repeated DNA Sequences
  • 208 Implement Trie (Prefix Tree)
  • 211 Add and Search Word – Data structure design
  • 218 The Skyline Problem
  • 232 Implement Queue using Stacks
  • 239 Sliding Window Maximum
  • 341 Flatten Nested List Iterator
  • 352 Data Stream as Disjoint Intervals
  • 432 All O’one Data Structure

Continue reading


leetcode 字符串

本次题解包括

  • 5. Longest Palindromic Substring
  • 6. ZigZag Conversion
  • 8. String to Integer (atoi)
  • 14. Longest Common Prefix
  • 28. Implement strStr()
  • 58. Length of Last Word
  • 125 . Valid Palindrome
  • 131 . Palindrome Partitioning
  • 132 . Palindrome Partitioning II
  • 214 . Shortest Palindrome
  • 336. Palindrome Pairs
  • 796. Rotate String
  • 816. Ambiguous Coordinates
  • 819. Most Common Word

Continue reading


leetcode Tree 整理版

本次题解为 leetcode tree 的整理,包括

  • 依照leetcode定义 自己写的createTree方法,便于测试中序遍历的下标和
  • 94 Binary Tree Inorder Traversal
  • 95 Unique Binary Search Trees II
  • 96 Unique Binary Search Trees
  • 98 Validate Binary Search Tree
  • 99 Recover Binary Search Tree
  • 100 Same Tree
  • 101 Symmetric Tree
  • 102 Binary Tree Level Order Traversal
  • 103 Binary Tree Zigzag Level Order Traversal
  • 104 Maximum Depth of Binary Tree
  • 105 Construct Binary Tree from Preorder and Inorder Traversal
  • 106 Construct Binary Tree from Inorder and Postorder Traversal
  • 107 Binary Tree Level Order Traversal II
  • 108 Convert Sorted Array to Binary Search Tree
  • 109 Convert Sorted List to Binary Search Tree
  • 110 Balanced Binary Tree
  • 111 Minimum Depth of Binary Tree
  • 112 Path Sum
  • 113 Path Sum II
  • 114 Flatten Binary Tree to Linked List
  • 116 Populating Next Right Pointers in Each Node
  • 117 Populating Next Right Pointers in Each Node II
  • 124 Binary Tree Maximum Path Sum
  • 129 Sum Root to Leaf Numbers
  • 144 Binary Tree Preorder Traversal
  • 145 Binary Tree Postorder Traversal
  • 173 Binary Search Tree Iterator
  • 199 Binary Tree Right Side View
  • 222 Count Complete Tree Nodes
  • 226 Invert Binary Tree
  • 230 Kth Smallest Element in a BST
  • 235 Lowest Common Ancestor of a Binary Search Tree
  • 236 Lowest Common Ancestor of a Binary Tree
  • 257 Binary Tree Paths
  • 297 Serialize and Deserialize Binary Tree
  • 449. Serialize and Deserialize BST

Continue reading


『leetcode』递归/DFS

leetcode dfs 归纳整理 包括:

  • 17. Letter Combinations of a Phone Number
  • 22. Generate Parentheses
  • 39 Combination Sum
  • 40 Combination Sum II
  • 51 N-Queens
  • 52 N-Queens II
  • 77 Combinations
  • 78 Subsets
  • 79 Word Search
  • 90 Subsets II
  • 200 Number of Islands
  • 216 Combination Sum III
  • 241 Different Ways to Add Parentheses
  • 282 Expression Add Operators
  • 797. All Paths From Source to Target

Continue reading