友情支持

如果您觉得这个笔记对您有所帮助,看在D瓜哥码这么多字的辛苦上,请友情支持一下,D瓜哥感激不尽,😜

支付宝

微信

有些打赏的朋友希望可以加个好友,欢迎关注D 瓜哥的微信公众号,这样就可以通过公众号的回复直接给我发信息。

wx jikerizhi

公众号的微信号是: jikerizhi因为众所周知的原因,有时图片加载不出来。 如果图片加载不出来可以直接通过搜索微信号来查找我的公众号。

刷题随想

  1. 215. Kth Largest Element in an Array 没想到快速排序的分区算法,竟然可以用于做快速选择?!神奇… 可惜的是,这题目以前做过,现在都给忘完了…

  2. 437. Path Sum III 前缀和的解法还需要再思考思考!

解题技巧

  1. 树形 DP 套路

  2. 前缀和

  3. 树的 Morris 遍历

    1. 基于 Morris 遍历的中序排列已经掌握,前序,尤其是后续还需要加强。

  4. 二分搜索怎样可以确定地取左右端点?

quick sort 01

未知

  1. 239. Sliding Window Maximum 的一个解题方法与稀疏表(Sparse Table)相识。稀疏表(Sparse Table)是什么?

TODO

感慨

问题也懂,代码也可以写出来,但是写的不够简洁优美,怎么办?

解题范式

  1. Two Pointer 双指针

    1. Pair with Target Sum (easy)

    2. Find Non-Duplicate Number Instances (easy)

    3. Squaring a Sorted Array (easy)

    4. Triplet Sum to Zero (medium)

    5. Triplet Sum Close to Target (medium)

    6. Triplets with Smaller Sum (medium)

    7. Subarrays with Product Less than a Target (medium)

    8. Dutch National Flag Problem (medium)

    9. Problem Challenge 1: Quadruple Sum to Target (medium)

    10. Problem Challenge 2: Comparing Strings containing Backspaces (medium)

    11. Problem Challenge 3: Minimum Window Sort (medium)

  2. Fast & Slow Pointers 快慢指针

    1. LinkedList Cycle (easy)

    2. Middle of the LinkedList (easy)

    3. Start of LinkedList Cycle (medium)

    4. Happy Number (medium)

    5. Problem Challenge 1: Palindrome LinkedList (medium)

    6. Problem Challenge 2: Rearrange a LinkedList (medium)

    7. Problem Challenge 3: Cycle in a Circular Array (hard)

  3. Sliding Window 滑动窗口

    1. Maximum Sum Subarray of Size K (easy)

    2. Smallest Subarray With a Greater Sum (easy)

    3. Longest Substring with K Distinct Characters (medium)

    4. Fruits into Baskets (medium)

    5. Longest Substring with Same Letters after Replacement (hard)

    6. Longest Subarray with Ones after Replacement (hard)

    7. Problem Challenge 1: Permutation in a String (hard)

    8. Problem Challenge 2: String Anagrams (hard)

    9. Problem Challenge 3: Smallest Window containing Substring (hard)

    10. Problem Challenge 4: Words Concatenation (hard)

  4. Merge Intervals 区间合并

    1. Merge Intervals (medium)

    2. Insert Interval (medium)

    3. Intervals Intersection (medium)

    4. Conflicting Appointments (medium)

    5. Problem Challenge 1: Minimum Meeting Rooms (hard)

    6. Problem Challenge 2: Maximum CPU Load (hard)

    7. Problem Challenge 3: Employee Free Time (hard)

  5. Cyclic Sort 循环排序

    1. Cyclic Sort (easy)

    2. Find the Missing Number (easy)

    3. Find all Missing Numbers (easy)

    4. Find the Duplicate Number (easy)

    5. Find all Duplicate Numbers (easy)

    6. Problem Challenge 1: Find the Corrupt Pair (easy)

    7. Problem Challenge 2: 41. First Missing Positive

    8. Problem Challenge 3: [1539-kth-missing-positive-number]

  6. In-place Reversal of a LinkedList 原地链表翻转

    1. Reverse a LinkedList (easy)

    2. Reverse a Sub-list (medium)

    3. Reverse every K-element Sub-list (medium)

    4. Problem Challenge 1: Reverse alternating K-element Sub-list (medium)

    5. Problem Challenge 2: Rotate a LinkedList (medium)

  7. Stack 栈

    1. Operations on Stack

    2. Implementing Stack Data Structure

    3. Applications of Stack

    4. Problem 1: Balanced Parentheses

    5. Problem 2: Reverse a String

    6. Problem 3: Decimal to Binary Conversion

    7. Problem 4: Next Greater Element

    8. Problem 5: Sorting a Stack

    9. Problem 6: Simplify Path

  8. Monotonic Stack 单调栈

    1. Remove Nodes From Linked List (medium)

    2. Remove All Adjacent Duplicates In String (easy)

    3. Next Greater Element (easy)

    4. Daily Temperatures (easy)

    5. Remove All Adjacent Duplicates in String II (medium)

    6. Remove K Digits (hard)

  9. Hash Maps

    1. Introduction to Hash Tables

    2. Issues with Hash Tables

    3. Problem 1: First Non-repeating Character (easy)

    4. Problem 2: Largest Unique Number (easy)

    5. Problem 3: Maximum Number of Balloons (easy)

    6. Problem 4: Longest Palindrome(easy)

    7. Problem 5: Ransom Note (easy)

  10. Breadth First Search 广度优先搜索

    1. Binary Tree Level Order Traversal (easy)

    2. Reverse Level Order Traversal (easy)

    3. Zigzag Traversal (medium)

    4. Level Averages in a Binary Tree (easy)

    5. Minimum Depth of a Binary Tree (easy)

    6. Level Order Successor (easy)

    7. Connect Level Order Siblings (medium)

    8. Problem Challenge 1: Connect All Level Order Siblings (medium)

    9. Problem Challenge 2: Right View of a Binary Tree (easy)

  11. Depth First Search 深度优先搜索

    1. Binary Tree Path Sum (easy)

    2. All Paths for a Sum (medium)

    3. Sum of Path Numbers (medium)

    4. Path With Given Sequence (medium)

    5. Count Paths for a Sum (medium)

    6. Problem Challenge 1: Tree Diameter (medium)

    7. Problem Challenge 2: Path with Maximum Sum (hard)

  12. Graph 图

    1. Graph Representations

    2. Graph as an Abstract Data Type (ADT)

    3. Graph Traversal - Depth First Search(DFS)

    4. Graph Traversal - Breadth First Search (BFS)

    5. Problem 1: Find if Path Exists in Graph(easy)

    6. Problem 2: Number of Provinces (medium)

    7. Problem 3: Minimum Number of Vertices to Reach All Nodes(medium)

  13. Island (Matrix Traversal)

    1. Number of Islands (easy)

    2. Biggest Island (easy)

    3. Flood Fill (easy)

    4. Number of Closed Islands (easy)

    5. Problem Challenge 1 (easy)

    6. Problem Challenge 2 (medium)

    7. Problem Challenge 3 (medium)

  14. Two Heaps 双堆

    1. Find the Median of a Number Stream (medium)

    2. Sliding Window Median (hard)

    3. Maximize Capital (hard)

    4. Problem Challenge 1: Next Interval (hard)

  15. Subsets 子集

    1. Subsets (easy)

    2. Subsets With Duplicates (easy)

    3. Permutations (medium)

    4. String Permutations by changing case (medium)

    5. Balanced Parentheses (hard)

    6. Unique Generalized Abbreviations (hard)

    7. Problem Challenge 1: Evaluate Expression (hard)

    8. Problem Challenge 2: Structurally Unique Binary Search Trees (hard)

    9. Problem Challenge 3: Count of Structurally Unique Binary Search Trees (hard)

  16. Modified Binary Search 改造过的二分搜索

    1. Order-agnostic Binary Search (easy)

    2. Ceiling of a Number (medium)

    3. Next Letter (medium)

    4. Number Range (medium)

    5. Search in a Sorted Infinite Array (medium)

    6. Minimum Difference Element (medium)

    7. Bitonic Array Maximum (easy)

    8. Problem Challenge 1: Search Bitonic Array (medium)

    9. Problem Challenge 2: Search in Rotated Array (medium)

    10. Problem Challenge 3: Rotation Count (medium)

  17. Bitwise XOR

    1. Single Number (easy)

    2. Two Single Numbers (medium)

    3. Complement of Base 10 Number (medium)

    4. Problem Challenge 1: Flip and Invert an Image (hard)

  18. Top 'K' Elements 顶端 K 元素

    1. Top 'K' Numbers (easy)

    2. Kth Smallest Number (easy)

    3. 'K' Closest Points to the Origin (easy)

    4. Connect Ropes (easy)

    5. Top 'K' Frequent Numbers (medium)

    6. Frequency Sort (medium)

    7. Kth Largest Number in a Stream (medium)

    8. 'K' Closest Numbers (medium)

    9. Maximum Distinct Elements (medium)

    10. Sum of Elements (medium)

    11. Rearrange String (hard)

    12. Problem Challenge 1: Rearrange String K Distance Apart (hard)

    13. Problem Challenge 2: Scheduling Tasks (hard)

    14. Problem Challenge 3: Frequency Stack (hard)

  19. Greedy Algorithms 贪心算法

    1. Valid Palindrome II (easy)

    2. Maximum Length of Pair Chain (medium)

    3. Minimum Add to Make Parentheses Valid (medium)

    4. Remove Duplicate Letters (medium)

    5. Largest Palindromic Number (medium)

    6. Removing Minimum and Maximum From Array (medium)

  20. Dynamic Programming 动态规划

    1. 0/1 Knapsack (medium)

    2. Equal Subset Sum Partition (medium)

    3. Subset Sum (medium)

    4. Minimum Subset Sum Difference (hard)

    5. Problem Challenge 1: Count of Subset Sum (hard)

    6. Problem Challenge 2: Target Sum (hard)

  21. Backtracking 回溯

    1. Combination Sum (medium)

    2. Word Search (medium)

    3. Factor Combinations (medium)

    4. Split a String Into the Max Number of Unique Substrings (medium)

    5. Sudoku Solver (hard)

  22. Trie 前缀树

    1. Implement Trie (Prefix Tree) (medium)

    2. Index Pairs of a String (easy)

    3. Design Add and Search Words Data Structure (medium)

    4. Extra Characters in a String (medium)

    5. Search Suggestions System (medium)

  23. Topological Sort (Graph) 拓扑排序

    1. Topological Sort (medium)

    2. Tasks Scheduling (medium)

    3. Tasks Scheduling Order (medium)

    4. All Tasks Scheduling Orders (hard)

    5. Alien Dictionary (hard)

    6. Problem Challenge 1: Reconstructing a Sequence (hard)

    7. Problem Challenge 2: Minimum Height Trees (hard)

  24. Union Find Set 查并集

    1. Redundant Connection (medium)

    2. Number of Provinces (medium)

    3. Is Graph Bipartite? (medium)

    4. Path With Minimum Effort (medium)

  25. Ordered Set

    1. Merge Similar Items (easy)

    2. 132 Pattern (medium)

    3. My Calendar I (medium)

    4. Longest Continuous Subarray (medium)

  26. Prefix Sum 前缀和

    1. Find the Middle Index in Array (easy)

    2. Left and Right Sum Differences (easy)

    3. Maximum Size Subarray Sum Equals k (medium)

    4. Binary Subarrays With Sum (medium)

    5. Subarray Sums Divisible by K (medium)

    6. Sum of Absolute Differences in a Sorted Array (medium)

    7. Subarray Sum Equals K (medium)

  27. Difference Array 差分数组

  28. Multi-threaded

    1. Same Tree (medium)

    2. Invert Binary Tree (medium)

    3. Binary Search Tree Iterator (medium)

  29. K-way merge 多路归并