diff --git a/README.md b/README.md
index 729abf1fb..7abbfddb0 100644
--- a/README.md
+++ b/README.md
@@ -70,6 +70,23 @@ LeetCode Problems' Solutions
| # | Title | Solution | Difficulty |
| :-: | - | - | :-: |
+| 1788 | [Maximize the Beauty of the Garden](https://leetcode.com/problems/maximize-the-beauty-of-the-garden) 🔒 | [Go](problems/maximize-the-beauty-of-the-garden) | Hard |
+| 1787 | [Make the XOR of All Segments Equal to Zero](https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero "使所有区间的异或结果为零") | [Go](problems/make-the-xor-of-all-segments-equal-to-zero) | Hard |
+| 1786 | [Number of Restricted Paths From First to Last Node](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") | [Go](problems/number-of-restricted-paths-from-first-to-last-node) | Medium |
+| 1785 | [Minimum Elements to Add to Form a Given Sum](https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum "构成特定和需要添加的最少元素") | [Go](problems/minimum-elements-to-add-to-form-a-given-sum) | Medium |
+| 1784 | [Check if Binary String Has at Most One Segment of Ones](https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones "检查二进制字符串字段") | [Go](problems/check-if-binary-string-has-at-most-one-segment-of-ones) | Easy |
+| 1783 | [Grand Slam Titles](https://leetcode.com/problems/grand-slam-titles) 🔒 | [MySQL](problems/grand-slam-titles) | Medium |
+| 1782 | [Count Pairs Of Nodes](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目") | [Go](problems/count-pairs-of-nodes) | Hard |
+| 1781 | [Sum of Beauty of All Substrings](https://leetcode.com/problems/sum-of-beauty-of-all-substrings "所有子字符串美丽值之和") | [Go](problems/sum-of-beauty-of-all-substrings) | Medium |
+| 1780 | [Check if Number is a Sum of Powers of Three](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three "判断一个数字是否可以表示成三的幂的和") | [Go](problems/check-if-number-is-a-sum-of-powers-of-three) | Medium |
+| 1779 | [Find Nearest Point That Has the Same X or Y Coordinate](https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate "找到最近的有相同 X 或 Y 坐标的点") | [Go](problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | Easy |
+| 1778 | [Shortest Path in a Hidden Grid](https://leetcode.com/problems/shortest-path-in-a-hidden-grid) 🔒 | [Go](problems/shortest-path-in-a-hidden-grid) | Medium |
+| 1777 | [Product's Price for Each Store](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格") 🔒 | [MySQL](problems/products-price-for-each-store) | Easy |
+| 1776 | [Car Fleet II](https://leetcode.com/problems/car-fleet-ii "车队 II") | [Go](problems/car-fleet-ii) | Hard |
+| 1775 | [Equal Sum Arrays With Minimum Number of Operations](https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations "通过最少操作次数使数组的和相等") | [Go](problems/equal-sum-arrays-with-minimum-number-of-operations) | Medium |
+| 1774 | [Closest Dessert Cost](https://leetcode.com/problems/closest-dessert-cost "最接近目标价格的甜点成本") | [Go](problems/closest-dessert-cost) | Medium |
+| 1773 | [Count Items Matching a Rule](https://leetcode.com/problems/count-items-matching-a-rule "统计匹配检索规则的物品数量") | [Go](problems/count-items-matching-a-rule) | Easy |
+| 1772 | [Sort Features by Popularity](https://leetcode.com/problems/sort-features-by-popularity "按受欢迎程度排列功能") 🔒 | [Go](problems/sort-features-by-popularity) | Medium |
| 1771 | [Maximize Palindrome Length From Subsequences](https://leetcode.com/problems/maximize-palindrome-length-from-subsequences "由子序列构造的最长回文串的长度") | [Go](problems/maximize-palindrome-length-from-subsequences) | Hard |
| 1770 | [Maximum Score from Performing Multiplication Operations](https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations "执行乘法运算的最大分数") | [Go](problems/maximum-score-from-performing-multiplication-operations) | Medium |
| 1769 | [Minimum Number of Operations to Move All Balls to Each Box](https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box "移动所有球到每个盒子所需的最小操作数") | [Go](problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | Medium |
@@ -79,13 +96,13 @@ LeetCode Problems' Solutions
| 1765 | [Map of Highest Peak](https://leetcode.com/problems/map-of-highest-peak "地图中的最高点") | [Go](problems/map-of-highest-peak) | Medium |
| 1764 | [Form Array by Concatenating Subarrays of Another Array](https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array "通过连接另一个数组的子数组得到一个数组") | [Go](problems/form-array-by-concatenating-subarrays-of-another-array) | Medium |
| 1763 | [Longest Nice Substring](https://leetcode.com/problems/longest-nice-substring "最长的美好子字符串") | [Go](problems/longest-nice-substring) | Easy |
-| 1762 | [Buildings With an Ocean View](https://leetcode.com/problems/buildings-with-an-ocean-view) 🔒 | [Go](problems/buildings-with-an-ocean-view) | Medium |
+| 1762 | [Buildings With an Ocean View](https://leetcode.com/problems/buildings-with-an-ocean-view "能看到海景的建筑物") 🔒 | [Go](problems/buildings-with-an-ocean-view) | Medium |
| 1761 | [Minimum Degree of a Connected Trio in a Graph](https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph "一个图中连通三元组的最小度数") | [Go](problems/minimum-degree-of-a-connected-trio-in-a-graph) | Hard |
| 1760 | [Minimum Limit of Balls in a Bag](https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag "袋子里最少数目的球") | [Go](problems/minimum-limit-of-balls-in-a-bag) | Medium |
| 1759 | [Count Number of Homogenous Substrings](https://leetcode.com/problems/count-number-of-homogenous-substrings "统计同构子字符串的数目") | [Go](problems/count-number-of-homogenous-substrings) | Medium |
| 1758 | [Minimum Changes To Make Alternating Binary String](https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string "生成交替二进制字符串的最少操作数") | [Go](problems/minimum-changes-to-make-alternating-binary-string) | Easy |
-| 1757 | [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products) 🔒 | [MySQL](problems/recyclable-and-low-fat-products) | Easy |
-| 1756 | [Design Most Recently Used Queue](https://leetcode.com/problems/design-most-recently-used-queue) 🔒 | [Go](problems/design-most-recently-used-queue) | Medium |
+| 1757 | [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products "可回收且低脂的产品") 🔒 | [MySQL](problems/recyclable-and-low-fat-products) | Easy |
+| 1756 | [Design Most Recently Used Queue](https://leetcode.com/problems/design-most-recently-used-queue "设计最近使用(MRU)队列") 🔒 | [Go](problems/design-most-recently-used-queue) | Medium |
| 1755 | [Closest Subsequence Sum](https://leetcode.com/problems/closest-subsequence-sum "最接近目标值的子序列和") | [Go](problems/closest-subsequence-sum) | Hard |
| 1754 | [Largest Merge Of Two Strings](https://leetcode.com/problems/largest-merge-of-two-strings "构造字典序最大的合并字符串") | [Go](problems/largest-merge-of-two-strings) | Medium |
| 1753 | [Maximum Score From Removing Stones](https://leetcode.com/problems/maximum-score-from-removing-stones "移除石子的最大得分") | [Go](problems/maximum-score-from-removing-stones) | Medium |
@@ -443,7 +460,7 @@ LeetCode Problems' Solutions
| 1401 | [Circle and Rectangle Overlapping](https://leetcode.com/problems/circle-and-rectangle-overlapping "圆和矩形是否有重叠") | [Go](problems/circle-and-rectangle-overlapping) | Medium |
| 1400 | [Construct K Palindrome Strings](https://leetcode.com/problems/construct-k-palindrome-strings "构造 K 个回文字符串") | [Go](problems/construct-k-palindrome-strings) | Medium |
| 1399 | [Count Largest Group](https://leetcode.com/problems/count-largest-group "统计最大组的数目") | [Go](problems/count-largest-group) | Easy |
-| 1398 | [Customers Who Bought Products A and B but Not C](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品A和产品B却没有购买产品C的顾客") 🔒 | [MySQL](problems/customers-who-bought-products-a-and-b-but-not-c) | Medium |
+| 1398 | [Customers Who Bought Products A and B but Not C](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品 A 和产品 B 却没有购买产品 C 的顾客") 🔒 | [MySQL](problems/customers-who-bought-products-a-and-b-but-not-c) | Medium |
| 1397 | [Find All Good Strings](https://leetcode.com/problems/find-all-good-strings "找到所有好字符串") | [Go](problems/find-all-good-strings) | Hard |
| 1396 | [Design Underground System](https://leetcode.com/problems/design-underground-system "设计地铁系统") | [Go](problems/design-underground-system) | Medium |
| 1395 | [Count Number of Teams](https://leetcode.com/problems/count-number-of-teams "统计作战单位数") | [Go](problems/count-number-of-teams) | Medium |
diff --git a/problems/add-two-numbers/README.md b/problems/add-two-numbers/README.md
index f1038803f..2648e97af 100644
--- a/problems/add-two-numbers/README.md
+++ b/problems/add-two-numbers/README.md
@@ -55,7 +55,7 @@
### Similar Questions
1. [Multiply Strings](../multiply-strings) (Medium)
1. [Add Binary](../add-binary) (Easy)
- 1. [Sum of Two Integers](../sum-of-two-integers) (Easy)
+ 1. [Sum of Two Integers](../sum-of-two-integers) (Medium)
1. [Add Strings](../add-strings) (Easy)
1. [Add Two Numbers II](../add-two-numbers-ii) (Medium)
1. [Add to Array-Form of Integer](../add-to-array-form-of-integer) (Easy)
diff --git a/problems/all-possible-full-binary-trees/README.md b/problems/all-possible-full-binary-trees/README.md
index 168409c86..b9d4707df 100644
--- a/problems/all-possible-full-binary-trees/README.md
+++ b/problems/all-possible-full-binary-trees/README.md
@@ -11,31 +11,32 @@
## [894. All Possible Full Binary Trees (Medium)](https://leetcode.com/problems/all-possible-full-binary-trees "所有可能的满二叉树")
-
A full binary tree is a binary tree where each node has exactly 0 or 2 children.
+Given an integer n
, return a list of all possible full binary trees with n
nodes. Each node of each tree in the answer must have Node.val == 0
.
-Return a list of all possible full binary trees with N
nodes. Each element of the answer is the root node of one possible tree.
+Each element of the answer is the root node of one possible tree. You may return the final list of trees in any order.
-Each node
of each tree in the answer must have node.val = 0
.
-
-You may return the final list of trees in any order.
+A full binary tree is a binary tree where each node has exactly 0
or 2
children.
-
Example 1:
+
+
+Input: n = 7
+Output: [[0,0,0,null,null,0,0,null,null,0,0],[0,0,0,null,null,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,null,null,null,null,0,0],[0,0,0,0,0,null,null,0,0]]
+
+
+Example 2:
-Input: 7
-Output: [[0,0,0,null,null,0,0,null,null,0,0],[0,0,0,null,null,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,null,null,null,null,0,0],[0,0,0,0,0,null,null,0,0]]
-Explanation:
-
+Input: n = 3
+Output: [[0,0,0]]
-
-Note:
+Constraints:
- 1 <= N <= 20
+ 1 <= n <= 20
### Related Topics
diff --git a/problems/arithmetic-slices/README.md b/problems/arithmetic-slices/README.md
index 220578503..75d5d0a70 100644
--- a/problems/arithmetic-slices/README.md
+++ b/problems/arithmetic-slices/README.md
@@ -11,37 +11,40 @@
## [413. Arithmetic Slices (Medium)](https://leetcode.com/problems/arithmetic-slices "等差数列划分")
-A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.
+An integer array is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.
-For example, these are arithmetic sequences:
+
+ - For example,
[1,3,5,7,9]
, [7,7,7,7]
, and [3,-1,-5,-9]
are arithmetic sequences.
+
-
-1, 3, 5, 7, 9
-7, 7, 7, 7
-3, -1, -5, -9
-
-The following sequence is not arithmetic.
+Given an integer array nums
, return the number of arithmetic subarrays of nums
.
-
-1, 1, 2, 5, 7
-
+A subarray is a contiguous subsequence of the array.
-A zero-indexed array A consisting of N numbers is given. A slice of that array is any pair of integers (P, Q) such that 0 <= P < Q < N.
+
+Example 1:
-A slice (P, Q) of the array A is called arithmetic if the sequence:
-A[P], A[P + 1], ..., A[Q - 1], A[Q] is arithmetic. In particular, this means that P + 1 < Q.
-
-The function should return the number of arithmetic slices in the array A.
-
+
+Input: nums = [1,2,3,4]
+Output: 3
+Explanation: We have 3 arithmetic slices in nums: [1, 2, 3], [2, 3, 4] and [1,2,3,4] itself.
+
-Example:
+Example 2:
-A = [1, 2, 3, 4]
-
-return: 3, for 3 arithmetic slices in A: [1, 2, 3], [2, 3, 4] and [1, 2, 3, 4] itself.
+Input: nums = [1]
+Output: 0
+
+Constraints:
+
+
+ 1 <= nums.length <= 5000
+ -1000 <= nums[i] <= 1000
+
+
### Related Topics
[[Math](../../tag/math/README.md)]
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
diff --git a/problems/available-captures-for-rook/README.md b/problems/available-captures-for-rook/README.md
index 4ccfa4383..3e5962fd5 100644
--- a/problems/available-captures-for-rook/README.md
+++ b/problems/available-captures-for-rook/README.md
@@ -11,56 +11,46 @@
## [999. Available Captures for Rook (Easy)](https://leetcode.com/problems/available-captures-for-rook "可以被一步捕获的棋子数")
-On an 8 x 8 chessboard, there is one white rook. There also may be empty squares, white bishops, and black pawns. These are given as characters 'R', '.', 'B', and 'p' respectively. Uppercase characters represent white pieces, and lowercase characters represent black pieces.
+On an 8 x 8
chessboard, there is exactly one white rook 'R'
and some number of white bishops 'B'
, black pawns 'p'
, and empty squares '.'
.
-The rook moves as in the rules of Chess: it chooses one of four cardinal directions (north, east, west, and south), then moves in that direction until it chooses to stop, reaches the edge of the board, or captures an opposite colored pawn by moving to the same square it occupies. Also, rooks cannot move into the same square as other friendly bishops.
+When the rook moves, it chooses one of four cardinal directions (north, east, south, or west), then moves in that direction until it chooses to stop, reaches the edge of the board, captures a black pawn, or is blocked by a white bishop. A rook is considered attacking a pawn if the rook can capture the pawn on the rook's turn. The number of available captures for the white rook is the number of pawns that the rook is attacking.
-Return the number of pawns the rook can capture in one move.
+Return the number of available captures for the white rook.
-
Example 1:
-
-
-
+
-Input: [[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".","R",".",".",".","p"],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]
-Output: 3
-Explanation:
-In this example the rook is able to capture all the pawns.
+Input: board = [[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".","R",".",".",".","p"],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]
+Output: 3
+Explanation: In this example, the rook is attacking all the pawns.
Example 2:
-
-
-
+
-Input: [[".",".",".",".",".",".",".","."],[".","p","p","p","p","p",".","."],[".","p","p","B","p","p",".","."],[".","p","B","R","B","p",".","."],[".","p","p","B","p","p",".","."],[".","p","p","p","p","p",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]
-Output: 0
-Explanation:
-Bishops are blocking the rook to capture any pawn.
+Input: board = [[".",".",".",".",".",".",".","."],[".","p","p","p","p","p",".","."],[".","p","p","B","p","p",".","."],[".","p","B","R","B","p",".","."],[".","p","p","B","p","p",".","."],[".","p","p","p","p","p",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]
+Output: 0
+Explanation: The bishops are blocking the rook from attacking any of the pawns.
Example 3:
-
-
-
+
-Input: [[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".","p",".",".",".","."],["p","p",".","R",".","p","B","."],[".",".",".",".",".",".",".","."],[".",".",".","B",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".",".",".",".",".","."]]
-Output: 3
-Explanation:
-The rook can capture the pawns at positions b5, d6 and f5.
+Input: board = [[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".","p",".",".",".","."],["p","p",".","R",".","p","B","."],[".",".",".",".",".",".",".","."],[".",".",".","B",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".",".",".",".",".","."]]
+Output: 3
+Explanation: The rook is attacking the pawns at positions b5, d6, and f5.
+Constraints:
-Note:
-
-
- board.length == board[i].length == 8
- board[i][j]
is either 'R'
, '.'
, 'B'
, or 'p'
+
+ board.length == 8
+ board[i].length == 8
+ board[i][j]
is either 'R'
, '.'
, 'B'
, or 'p'
- There is exactly one cell with
board[i][j] == 'R'
-
+
### Related Topics
[[Array](../../tag/array/README.md)]
diff --git a/problems/average-of-levels-in-binary-tree/README.md b/problems/average-of-levels-in-binary-tree/README.md
index da85b7d73..98c382d1f 100644
--- a/problems/average-of-levels-in-binary-tree/README.md
+++ b/problems/average-of-levels-in-binary-tree/README.md
@@ -11,27 +11,31 @@
## [637. Average of Levels in Binary Tree (Easy)](https://leetcode.com/problems/average-of-levels-in-binary-tree "二叉树的层平均值")
-Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.
+Given the root
of a binary tree, return the average value of the nodes on each level in the form of an array. Answers within 10-5
of the actual answer will be accepted.
+
+Example 1:
+
+
+Input: root = [3,9,20,null,15,7]
+Output: [3.00000,14.50000,11.00000]
+Explanation: The average value of nodes on level 0 is 3, on level 1 is 14.5, and on level 2 is 11.
+Hence return [3, 14.5, 11].
+
-Example 1:
+
Example 2:
+
-Input:
- 3
- / \
- 9 20
- / \
- 15 7
-Output: [3, 14.5, 11]
-Explanation:
-The average value of nodes on level 0 is 3, on level 1 is 14.5, and on level 2 is 11. Hence return [3, 14.5, 11].
+Input: root = [3,9,20,15,7]
+Output: [3.00000,14.50000,11.00000]
-
-Note:
-
-- The range of node's value is in the range of 32-bit signed integer.
-
-
+
+Constraints:
+
+
+ - The number of nodes in the tree is in the range
[1, 104]
.
+ -231 <= Node.val <= 231 - 1
+
### Related Topics
[[Tree](../../tag/tree/README.md)]
diff --git a/problems/best-time-to-buy-and-sell-stock-ii/README.md b/problems/best-time-to-buy-and-sell-stock-ii/README.md
index 94814f1bc..8052d1e8b 100644
--- a/problems/best-time-to-buy-and-sell-stock-ii/README.md
+++ b/problems/best-time-to-buy-and-sell-stock-ii/README.md
@@ -11,7 +11,7 @@
## [122. Best Time to Buy and Sell Stock II (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii "买卖股票的最佳时机 II")
-You are given an array prices
for which the ith
element is the price of a given stock on day i
.
+You are given an array prices
where prices[i]
is the price of a given stock on the ith
day.
Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).
diff --git a/problems/best-time-to-buy-and-sell-stock-iii/README.md b/problems/best-time-to-buy-and-sell-stock-iii/README.md
index fccf2e5fe..47e162791 100644
--- a/problems/best-time-to-buy-and-sell-stock-iii/README.md
+++ b/problems/best-time-to-buy-and-sell-stock-iii/README.md
@@ -11,11 +11,11 @@
## [123. Best Time to Buy and Sell Stock III (Hard)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii "买卖股票的最佳时机 III")
-Say you have an array for which the ith element is the price of a given stock on day i.
+You are given an array prices
where prices[i]
is the price of a given stock on the ith
day.
-Design an algorithm to find the maximum profit. You may complete at most two transactions.
+Find the maximum profit you can achieve. You may complete at most two transactions.
-Note: You may not engage in multiple transactions at the same time (i.e., you must sell the stock before you buy again).
+Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).
Example 1:
@@ -54,8 +54,8 @@ Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are
Constraints:
- 1 <= prices.length <= 105
- 0 <= prices[i] <= 105
+ 1 <= prices.length <= 105
+ 0 <= prices[i] <= 105
### Related Topics
diff --git a/problems/best-time-to-buy-and-sell-stock-iv/README.md b/problems/best-time-to-buy-and-sell-stock-iv/README.md
index 4eb4c93a2..5683ae33f 100644
--- a/problems/best-time-to-buy-and-sell-stock-iv/README.md
+++ b/problems/best-time-to-buy-and-sell-stock-iv/README.md
@@ -11,11 +11,11 @@
## [188. Best Time to Buy and Sell Stock IV (Hard)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv "买卖股票的最佳时机 IV")
-You are given an integer array prices
where prices[i]
is the price of a given stock on the ith
day.
+You are given an integer array prices
where prices[i]
is the price of a given stock on the ith
day, and an integer k
.
-Design an algorithm to find the maximum profit. You may complete at most k
transactions.
+Find the maximum profit you can achieve. You may complete at most k
transactions.
-Notice that you may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).
+Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).
Example 1:
diff --git a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md
index e57cb5155..98b415a4f 100644
--- a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md
+++ b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md
@@ -11,23 +11,40 @@
## [309. Best Time to Buy and Sell Stock with Cooldown (Medium)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown "最佳买卖股票时机含冷冻期")
-Say you have an array for which the ith element is the price of a given stock on day i.
+You are given an array prices
where prices[i]
is the price of a given stock on the ith
day.
-Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times) with the following restrictions:
+Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions:
- - You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
- - After you sell your stock, you cannot buy stock on next day. (ie, cooldown 1 day)
+ - After you sell your stock, you cannot buy stock on the next day (i.e., cooldown one day).
-Example:
+Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).
+
+
+Example 1:
-Input: [1,2,3,0,2]
-Output: 3
+Input: prices = [1,2,3,0,2]
+Output: 3
Explanation: transactions = [buy, sell, cooldown, buy, sell]
+Example 2:
+
+
+Input: prices = [1]
+Output: 0
+
+
+
+Constraints:
+
+
+ 1 <= prices.length <= 5000
+ 0 <= prices[i] <= 1000
+
+
### Related Topics
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
diff --git a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md
index b1ad894a5..858166250 100644
--- a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md
+++ b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md
@@ -11,24 +11,40 @@
## [714. Best Time to Buy and Sell Stock with Transaction Fee (Medium)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee "买卖股票的最佳时机含手续费")
-Your are given an array of integers prices
, for which the i
-th element is the price of a given stock on day i
; and a non-negative integer fee
representing a transaction fee.
-You may complete as many transactions as you like, but you need to pay the transaction fee for each transaction. You may not buy more than 1 share of a stock at a time (ie. you must sell the stock share before you buy again.)
-Return the maximum profit you can make.
+You are given an array prices
where prices[i]
is the price of a given stock on the ith
day, and an integer fee
representing a transaction fee.
+
+Find the maximum profit you can achieve. You may complete as many transactions as you like, but you need to pay the transaction fee for each transaction.
+
+Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).
+
+
+Example 1:
+
+
+Input: prices = [1,3,2,8,4,9], fee = 2
+Output: 8
+Explanation: The maximum profit can be achieved by:
+- Buying at prices[0] = 1
+- Selling at prices[3] = 8
+- Buying at prices[4] = 4
+- Selling at prices[5] = 9
+The total profit is ((8 - 1) - 2) + ((9 - 4) - 2) = 8.
+
+
+Example 2:
-Example 1:
-Input: prices = [1, 3, 2, 8, 4, 9], fee = 2
-Output: 8
-Explanation: The maximum profit can be achieved by:
-
Buying at prices[0] = 1Selling at prices[3] = 8Buying at prices[4] = 4Selling at prices[5] = 9The total profit is ((8 - 1) - 2) + ((9 - 4) - 2) = 8.
+Input: prices = [1,3,7,5,10,3], fee = 3
+Output: 6
-
-Note:
-
0 < prices.length <= 50000
.
-0 < prices[i] < 50000
.
-0 <= fee < 50000
.
-
+
+Constraints:
+
+
+ 1 < prices.length <= 5 * 104
+ 0 < prices[i], fee < 5 * 104
+
### Related Topics
[[Greedy](../../tag/greedy/README.md)]
diff --git a/problems/binary-search-tree-iterator/README.md b/problems/binary-search-tree-iterator/README.md
index 8254542ad..aaac3d2a1 100644
--- a/problems/binary-search-tree-iterator/README.md
+++ b/problems/binary-search-tree-iterator/README.md
@@ -11,7 +11,7 @@
## [173. Binary Search Tree Iterator (Medium)](https://leetcode.com/problems/binary-search-tree-iterator "二叉搜索树迭代器")
-Implement the BSTIterator
class that represents an iterator over the in-order traversal of a binary search tree (BST):
+Implement the BSTIterator
class that represents an iterator over the in-order traversal of a binary search tree (BST):
BSTIterator(TreeNode root)
Initializes an object of the BSTIterator
class. The root
of the BST is given as part of the constructor. The pointer should be initialized to a non-existent number smaller than any element in the BST.
@@ -21,7 +21,7 @@
Notice that by initializing the pointer to a non-existent smallest number, the first call to next()
will return the smallest element in the BST.
-You may assume that next()
calls will always be valid. That is, there will be at least a next number in the in-order traversal when next()
is called.
+You may assume that next()
calls will always be valid. That is, there will be at least a next number in the in-order traversal when next()
is called.
Example 1:
diff --git a/problems/binary-search/README.md b/problems/binary-search/README.md
index 34d2cf28e..01078452d 100644
--- a/problems/binary-search/README.md
+++ b/problems/binary-search/README.md
@@ -11,35 +11,34 @@
## [704. Binary Search (Easy)](https://leetcode.com/problems/binary-search "二分查找")
-Given a sorted (in ascending order) integer array nums
of n
elements and a target
value, write a function to search target
in nums
. If target
exists, then return its index, otherwise return -1
.
+Given an array of integers nums
which is sorted in ascending order, and an integer target
, write a function to search target
in nums
. If target
exists, then return its index. Otherwise, return -1
.
-
-Example 1:
+
+Example 1:
-Input: nums
= [-1,0,3,5,9,12], target
= 9
+Input: nums = [-1,0,3,5,9,12], target = 9
Output: 4
-Explanation: 9 exists in nums
and its index is 4
-
+Explanation: 9 exists in nums and its index is 4
Example 2:
-Input: nums
= [-1,0,3,5,9,12], target
= 2
+Input: nums = [-1,0,3,5,9,12], target = 2
Output: -1
-Explanation: 2 does not exist in nums
so return -1
+Explanation: 2 does not exist in nums so return -1
-
-Note:
-
-
- - You may assume that all elements in
nums
are unique.
- n
will be in the range [1, 10000]
.
- - The value of each element in
nums
will be in the range [-9999, 9999]
.
-
+Constraints:
+
+
+ 1 <= nums.length <= 104
+ -9999 <= nums[i], target <= 9999
+ - All the integers in
nums
are unique.
+ nums
is sorted in an ascending order.
+
### Related Topics
[[Binary Search](../../tag/binary-search/README.md)]
diff --git a/problems/binary-tree-tilt/README.md b/problems/binary-tree-tilt/README.md
index 1f27ea1c0..508eecacf 100644
--- a/problems/binary-tree-tilt/README.md
+++ b/problems/binary-tree-tilt/README.md
@@ -24,7 +24,7 @@
Explanation:
Tilt of node 2 : |0-0| = 0 (no children)
Tilt of node 3 : |0-0| = 0 (no children)
-Tile of node 1 : |2-3| = 1 (left subtree is just left child, so sum is 2; right subtree is just right child, so sum is 3)
+Tilt of node 1 : |2-3| = 1 (left subtree is just left child, so sum is 2; right subtree is just right child, so sum is 3)
Sum of every tilt : 0 + 0 + 1 = 1
diff --git a/problems/bitwise-and-of-numbers-range/README.md b/problems/bitwise-and-of-numbers-range/README.md
index cf9e4d9c7..fb838725c 100644
--- a/problems/bitwise-and-of-numbers-range/README.md
+++ b/problems/bitwise-and-of-numbers-range/README.md
@@ -11,20 +11,36 @@
## [201. Bitwise AND of Numbers Range (Medium)](https://leetcode.com/problems/bitwise-and-of-numbers-range "数字范围按位与")
-Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.
+Given two integers left
and right
that represent the range [left, right]
, return the bitwise AND of all numbers in this range, inclusive.
+
Example 1:
-Input: [5,7]
+Input: left = 5, right = 7
Output: 4
Example 2:
-Input: [0,1]
-Output: 0
+Input: left = 0, right = 0
+Output: 0
+
+
+Example 3:
+
+
+Input: left = 1, right = 2147483647
+Output: 0
+
+
+
+Constraints:
+
+
+ 0 <= left <= right <= 231 - 1
+
### Related Topics
[[Bit Manipulation](../../tag/bit-manipulation/README.md)]
diff --git a/problems/buddy-strings/README.md b/problems/buddy-strings/README.md
index 9b53500ae..dff223507 100644
--- a/problems/buddy-strings/README.md
+++ b/problems/buddy-strings/README.md
@@ -11,56 +11,48 @@
## [859. Buddy Strings (Easy)](https://leetcode.com/problems/buddy-strings "亲密字符串")
-Given two strings A
and B
of lowercase letters, return true
if you can swap two letters in A
so the result is equal to B
, otherwise, return false
.
+Given two strings a
and b
, return true
if you can swap two letters in a
so the result is equal to b
, otherwise, return false
.
-Swapping letters is defined as taking two indices i
and j
(0-indexed) such that i != j
and swapping the characters at A[i]
and A[j]
. For example, swapping at indices 0
and 2
in "abcd"
results in "cbad"
.
+Swapping letters is defined as taking two indices i
and j
(0-indexed) such that i != j
and swapping the characters at a[i]
and b[j]
. For example, swapping at indices 0
and 2
in "abcd"
results in "cbad"
.
Example 1:
-Input: A = "ab", B = "ba"
+Input: a = "ab", b = "ba"
Output: true
-Explanation: You can swap A[0] = 'a' and A[1] = 'b' to get "ba", which is equal to B.
+Explanation: You can swap a[0] = 'a' and a[1] = 'b' to get "ba", which is equal to b.
Example 2:
-Input: A = "ab", B = "ab"
+Input: a = "ab", b = "ab"
Output: false
-Explanation: The only letters you can swap are A[0] = 'a' and A[1] = 'b', which results in "ba" != B.
+Explanation: The only letters you can swap are a[0] = 'a' and a[1] = 'b', which results in "ba" != b.
Example 3:
-Input: A = "aa", B = "aa"
+Input: a = "aa", b = "aa"
Output: true
-Explanation: You can swap A[0] = 'a' and A[1] = 'a' to get "aa", which is equal to B.
+Explanation: You can swap a[0] = 'a' and a[1] = 'a' to get "aa", which is equal to b.
Example 4:
-Input: A = "aaaaaaabc", B = "aaaaaaacb"
+Input: a = "aaaaaaabc", b = "aaaaaaacb"
Output: true
-Example 5:
-
-
-Input: A = "", B = "aa"
-Output: false
-
-
Constraints:
- 0 <= A.length <= 20000
- 0 <= B.length <= 20000
- A
and B
consist of lowercase letters.
+ 1 <= a.length, b.length <= 2 * 104
+ a
and b
consist of lowercase letters.
### Related Topics
diff --git a/problems/buildings-with-an-ocean-view/README.md b/problems/buildings-with-an-ocean-view/README.md
index 6eaec32b0..694bb1f42 100644
--- a/problems/buildings-with-an-ocean-view/README.md
+++ b/problems/buildings-with-an-ocean-view/README.md
@@ -9,7 +9,7 @@
[Next >](../longest-nice-substring "Longest Nice Substring")
-## [1762. Buildings With an Ocean View (Medium)](https://leetcode.com/problems/buildings-with-an-ocean-view "")
+## [1762. Buildings With an Ocean View (Medium)](https://leetcode.com/problems/buildings-with-an-ocean-view "能看到海景的建筑物")
diff --git a/problems/car-fleet-ii/README.md b/problems/car-fleet-ii/README.md
new file mode 100644
index 000000000..3ea5843a2
--- /dev/null
+++ b/problems/car-fleet-ii/README.md
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+[< Previous](../equal-sum-arrays-with-minimum-number-of-operations "Equal Sum Arrays With Minimum Number of Operations")
+
+[Next >](../products-price-for-each-store "Product's Price for Each Store")
+
+## [1776. Car Fleet II (Hard)](https://leetcode.com/problems/car-fleet-ii "车队 II")
+
+There are n
cars traveling at different speeds in the same direction along a one-lane road. You are given an array cars
of length n
, where cars[i] = [positioni, speedi]
represents:
+
+
+ positioni
is the distance between the ith
car and the beginning of the road in meters. It is guaranteed that positioni < positioni+1
.
+ speedi
is the initial speed of the ith
car in meters per second.
+
+
+For simplicity, cars can be considered as points moving along the number line. Two cars collide when they occupy the same position. Once a car collides with another car, they unite and form a single car fleet. The cars in the formed fleet will have the same position and the same speed, which is the initial speed of the slowest car in the fleet.
+
+Return an array answer
, where answer[i]
is the time, in seconds, at which the ith
car collides with the next car, or -1
if the car does not collide with the next car. Answers within 10-5
of the actual answers are accepted.
+
+
+Example 1:
+
+
+Input: cars = [[1,2],[2,1],[4,3],[7,2]]
+Output: [1.00000,-1.00000,3.00000,-1.00000]
+Explanation: After exactly one second, the first car will collide with the second car, and form a car fleet with speed 1 m/s. After exactly 3 seconds, the third car will collide with the fourth car, and form a car fleet with speed 2 m/s.
+
+
+Example 2:
+
+
+Input: cars = [[3,4],[5,4],[6,3],[9,1]]
+Output: [2.00000,1.00000,1.50000,-1.00000]
+
+
+
+Constraints:
+
+
+ 1 <= cars.length <= 105
+ 1 <= positioni, speedi <= 106
+ positioni < positioni+1
+
+
+### Related Topics
+ [[Math](../../tag/math/README.md)]
+
+### Hints
+
+Hint 1
+We can simply ignore the merging of any car fleet, simply assume they cross each other. Now the aim is to find the first car to the right, which intersects with the current car before any other.
+
+
+
+Hint 2
+Assume we have already considered all cars to the right already, now the current car is to be considered. Let’s ignore all cars with speeds higher than the current car since the current car cannot intersect with those ones. Now, all cars to the right having speed strictly less than current car are to be considered. Now, for two cars c1 and c2 with positions p1 and p2 (p1 < p2) and speed s1 and s2 (s1 > s2), if c1 and c2 intersect before the current car and c2, then c1 can never be the first car of intersection for any car to the left of current car including current car. So we can remove that car from our consideration.
+
+
+
+Hint 3
+We can see that we can maintain candidate cars in this way using a stack, removing cars with speed greater than or equal to current car, and then removing cars which can never be first point of intersection. The first car after this process (if any) would be first point of intersection.
+
diff --git a/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md
new file mode 100644
index 000000000..315722b60
--- /dev/null
+++ b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+[< Previous](../grand-slam-titles "Grand Slam Titles")
+
+[Next >](../minimum-elements-to-add-to-form-a-given-sum "Minimum Elements to Add to Form a Given Sum")
+
+## [1784. Check if Binary String Has at Most One Segment of Ones (Easy)](https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones "检查二进制字符串字段")
+
+Given a binary string s
without leading zeros, return true
if s
contains at most one contiguous segment of ones. Otherwise, return false
.
+
+
+Example 1:
+
+
+Input: s = "1001"
+Output: false
+Explanation: The ones do not form a contiguous segment.
+
+
+Example 2:
+
+
+Input: s = "110"
+Output: true
+
+
+Constraints:
+
+
+ 1 <= s.length <= 100
+ s[i]
is either '0'
or '1'
.
+ s[0]
is '1'
.
+
+
+### Related Topics
+ [[Greedy](../../tag/greedy/README.md)]
+
+### Hints
+
+Hint 1
+It's guaranteed to have at least one segment
+
+
+
+Hint 2
+The string size is small so you can count all segments of ones with no that have no adjacent ones.
+
diff --git a/problems/check-if-number-is-a-sum-of-powers-of-three/README.md b/problems/check-if-number-is-a-sum-of-powers-of-three/README.md
new file mode 100644
index 000000000..3ae982ed7
--- /dev/null
+++ b/problems/check-if-number-is-a-sum-of-powers-of-three/README.md
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+[< Previous](../find-nearest-point-that-has-the-same-x-or-y-coordinate "Find Nearest Point That Has the Same X or Y Coordinate")
+
+[Next >](../sum-of-beauty-of-all-substrings "Sum of Beauty of All Substrings")
+
+## [1780. Check if Number is a Sum of Powers of Three (Medium)](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three "判断一个数字是否可以表示成三的幂的和")
+
+Given an integer n
, return true
if it is possible to represent n
as the sum of distinct powers of three. Otherwise, return false
.
+
+An integer y
is a power of three if there exists an integer x
such that y == 3x
.
+
+
+Example 1:
+
+
+Input: n = 12
+Output: true
+Explanation: 12 = 31 + 32
+
+
+Example 2:
+
+
+Input: n = 91
+Output: true
+Explanation: 91 = 30 + 32 + 34
+
+
+Example 3:
+
+
+Input: n = 21
+Output: false
+
+
+
+Constraints:
+
+
+
+### Related Topics
+ [[Recursion](../../tag/recursion/README.md)]
+ [[Math](../../tag/math/README.md)]
+ [[Backtracking](../../tag/backtracking/README.md)]
+
+### Hints
+
+Hint 1
+Let's note that the maximum power of 3 you'll use in your soln is 3^16
+
+
+
+Hint 2
+The number can not be represented as a sum of powers of 3 if it's ternary presentation has a 2 in it
+
diff --git a/problems/circular-array-loop/README.md b/problems/circular-array-loop/README.md
index 64aa6188a..ae64092e9 100644
--- a/problems/circular-array-loop/README.md
+++ b/problems/circular-array-loop/README.md
@@ -9,52 +9,69 @@
[Next >](../poor-pigs "Poor Pigs")
-## [457. Circular Array Loop (Medium)](https://leetcode.com/problems/circular-array-loop "环形数组循环")
+## [457. Circular Array Loop (Medium)](https://leetcode.com/problems/circular-array-loop "环形数组是否存在循环")
-You are given a circular array nums
of positive and negative integers. If a number k at an index is positive, then move forward k steps. Conversely, if it's negative (-k), move backward k steps. Since the array is circular, you may assume that the last element's next element is the first element, and the first element's previous element is the last element.
+You are playing a game involving a circular array of non-zero integers nums
. Each nums[i]
denotes the number of indices forward/backward you must move if you are located at index i
:
-Determine if there is a loop (or a cycle) in nums
. A cycle must start and end at the same index and the cycle's length > 1. Furthermore, movements in a cycle must all follow a single direction. In other words, a cycle must not consist of both forward and backward movements.
+
+ - If
nums[i]
is positive, move nums[i]
steps forward, and
+ - If
nums[i]
is negative, move nums[i]
steps backward.
+
-
+Since the array is circular, you may assume that moving forward from the last element puts you on the first element, and moving backwards from the first element puts you on the last element.
+
+A cycle in the array consists of a sequence of indices seq
of length k
where:
+
+
+ - Following the movement rules above results in the repeating index sequence
seq[0] -> seq[1] -> ... -> seq[k - 1] -> seq[0] -> ...
+ - Every
nums[seq[j]]
is either all positive or all negative.
+ k > 1
+
-Example 1:
+Return true
if there is a cycle in nums
, or false
otherwise.
+
+
+Example 1:
-Input: [2,-1,1,2,2]
-Output: true
-Explanation: There is a cycle, from index 0 -> 2 -> 3 -> 0. The cycle's length is 3.
+Input: nums = [2,-1,1,2,2]
+Output: true
+Explanation:
+There is a cycle from index 0 -> 2 -> 3 -> 0 -> ...
+The cycle's length is 3.
-Example 2:
+Example 2:
-Input: [-1,2]
-Output: false
-Explanation: The movement from index 1 -> 1 -> 1 ... is not a cycle, because the cycle's length is 1. By definition the cycle's length must be greater than 1.
+Input: nums = [-1,2]
+Output: false
+Explanation:
+The sequence from index 1 -> 1 -> 1 -> ... is not a cycle because the sequence's length is 1.
+By definition the sequence's length must be strictly greater than 1 to be a cycle.
-Example 3:
+Example 3:
-Input: [-2,1,-1,-2,-2]
-Output: false
-Explanation: The movement from index 1 -> 2 -> 1 -> ... is not a cycle, because movement from index 1 -> 2 is a forward movement, but movement from index 2 -> 1 is a backward movement. All movements in a cycle must follow a single direction.
+Input: nums = [-2,1,-1,-2,-2]
+Output: false
+Explanation:
+The sequence from index 1 -> 2 -> 1 -> ... is not a cycle because nums[1] is positive, but nums[2] is negative.
+Every nums[seq[j]] must be either all positive or all negative.
+
+Constraints:
-Note:
-
-
- - -1000 ≤ nums[i] ≤ 1000
- - nums[i] ≠ 0
- - 1 ≤ nums.length ≤ 5000
-
+
+ 1 <= nums.length <= 5000
+ -1000 <= nums[i] <= 1000
+ nums[i] != 0
+
-
-Follow up:
-
-Could you solve it in O(n) time complexity and O(1) extra space complexity?
+Follow up: Could you solve it in O(n)
time complexity and O(1)
extra space complexity?
### Related Topics
[[Array](../../tag/array/README.md)]
diff --git a/problems/closest-dessert-cost/README.md b/problems/closest-dessert-cost/README.md
new file mode 100644
index 000000000..89dcc5878
--- /dev/null
+++ b/problems/closest-dessert-cost/README.md
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+[< Previous](../count-items-matching-a-rule "Count Items Matching a Rule")
+
+[Next >](../equal-sum-arrays-with-minimum-number-of-operations "Equal Sum Arrays With Minimum Number of Operations")
+
+## [1774. Closest Dessert Cost (Medium)](https://leetcode.com/problems/closest-dessert-cost "最接近目标价格的甜点成本")
+
+You would like to make dessert and are preparing to buy the ingredients. You have n
ice cream base flavors and m
types of toppings to choose from. You must follow these rules when making your dessert:
+
+
+ - There must be exactly one ice cream base.
+ - You can add one or more types of topping or have no toppings at all.
+ - There are at most two of each type of topping.
+
+
+You are given three inputs:
+
+
+ baseCosts
, an integer array of length n
, where each baseCosts[i]
represents the price of the ith
ice cream base flavor.
+ toppingCosts
, an integer array of length m
, where each toppingCosts[i]
is the price of one of the ith
topping.
+ target
, an integer representing your target price for dessert.
+
+
+You want to make a dessert with a total cost as close to target
as possible.
+
+Return the closest possible cost of the dessert to target
. If there are multiple, return the lower one.
+
+
+Example 1:
+
+
+Input: baseCosts = [1,7], toppingCosts = [3,4], target = 10
+Output: 10
+Explanation: Consider the following combination (all 0-indexed):
+- Choose base 1: cost 7
+- Take 1 of topping 0: cost 1 x 3 = 3
+- Take 0 of topping 1: cost 0 x 4 = 0
+Total: 7 + 3 + 0 = 10.
+
+
+Example 2:
+
+
+Input: baseCosts = [2,3], toppingCosts = [4,5,100], target = 18
+Output: 17
+Explanation: Consider the following combination (all 0-indexed):
+- Choose base 1: cost 3
+- Take 1 of topping 0: cost 1 x 4 = 4
+- Take 2 of topping 1: cost 2 x 5 = 10
+- Take 0 of topping 2: cost 0 x 100 = 0
+Total: 3 + 4 + 10 + 0 = 17. You cannot make a dessert with a total cost of 18.
+
+
+Example 3:
+
+
+Input: baseCosts = [3,10], toppingCosts = [2,5], target = 9
+Output: 8
+Explanation: It is possible to make desserts with cost 8 and 10. Return 8 as it is the lower cost.
+
+
+Example 4:
+
+
+Input: baseCosts = [10], toppingCosts = [1], target = 1
+Output: 10
+Explanation: Notice that you don't have to have any toppings, but you must have exactly one base.
+
+
+Constraints:
+
+
+ n == baseCosts.length
+ m == toppingCosts.length
+ 1 <= n, m <= 10
+ 1 <= baseCosts[i], toppingCosts[i] <= 104
+ 1 <= target <= 104
+
+
+### Related Topics
+ [[Greedy](../../tag/greedy/README.md)]
+
+### Hints
+
+Hint 1
+As the constraints are not large, you can brute force and enumerate all the possibilities.
+
diff --git a/problems/construct-binary-search-tree-from-preorder-traversal/README.md b/problems/construct-binary-search-tree-from-preorder-traversal/README.md
index 31499290e..9e0f5594e 100644
--- a/problems/construct-binary-search-tree-from-preorder-traversal/README.md
+++ b/problems/construct-binary-search-tree-from-preorder-traversal/README.md
@@ -11,18 +11,27 @@
## [1008. Construct Binary Search Tree from Preorder Traversal (Medium)](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal "前序遍历构造二叉搜索树")
-Return the root node of a binary search tree that matches the given preorder
traversal.
+Given an array of integers preorder, which represents the preorder traversal of a BST (i.e., binary search tree), construct the tree and return its root.
-(Recall that a binary search tree is a binary tree where for every node, any descendant of node.left
has a value <
node.val
, and any descendant of node.right
has a value >
node.val
. Also recall that a preorder traversal displays the value of the node
first, then traverses node.left
, then traverses node.right
.)
+It is guaranteed that there is always possible to find a binary search tree with the given requirements for the given test cases.
-It's guaranteed that for the given test cases there is always possible to find a binary search tree with the given requirements.
+A binary search tree is a binary tree where for every node, any descendant of Node.left
has a value strictly less than Node.val
, and any descendant of Node.right
has a value strictly greater than Node.val
.
+A preorder traversal of a binary tree displays the value of the node first, then traverses Node.left
, then traverses Node.right
.
+
+
Example 1:
+
+
+Input: preorder = [8,5,1,7,10,12]
+Output: [8,5,10,1,7,null,12]
+
+
+Example 2:
-Input: [8,5,1,7,10,12]
-Output: [8,5,10,1,7,null,12]
-
+Input: preorder = [1,3]
+Output: [1,null,3]
@@ -30,8 +39,8 @@
1 <= preorder.length <= 100
- 1 <= preorder[i] <= 10^8
- - The values of
preorder
are distinct.
+ 1 <= preorder[i] <= 108
+ - All the values of
preorder
are unique.
### Related Topics
diff --git a/problems/container-with-most-water/README.md b/problems/container-with-most-water/README.md
index b4bb591b6..dfdce6ead 100644
--- a/problems/container-with-most-water/README.md
+++ b/problems/container-with-most-water/README.md
@@ -11,9 +11,9 @@
## [11. Container With Most Water (Medium)](https://leetcode.com/problems/container-with-most-water "盛最多水的容器")
-Given n
non-negative integers a1, a2, ..., an
, where each represents a point at coordinate (i, ai)
. n
vertical lines are drawn such that the two endpoints of the line i
is at (i, ai)
and (i, 0)
. Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.
+Given n
non-negative integers a1, a2, ..., an
, where each represents a point at coordinate (i, ai)
. n
vertical lines are drawn such that the two endpoints of the line i
is at (i, ai)
and (i, 0)
. Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.
-Notice that you may not slant the container.
+Notice that you may not slant the container.
Example 1:
@@ -50,8 +50,8 @@
n == height.length
- 2 <= n <= 3 * 104
- 0 <= height[i] <= 3 * 104
+ 2 <= n <= 105
+ 0 <= height[i] <= 104
### Related Topics
diff --git a/problems/contains-duplicate-ii/README.md b/problems/contains-duplicate-ii/README.md
index c90582922..0ccf3af4d 100644
--- a/problems/contains-duplicate-ii/README.md
+++ b/problems/contains-duplicate-ii/README.md
@@ -11,34 +11,38 @@
## [219. Contains Duplicate II (Easy)](https://leetcode.com/problems/contains-duplicate-ii "存在重复元素 II")
-Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k.
+Given an integer array nums
and an integer k
, return true
if there are two distinct indices i
and j
in the array such that nums[i] == nums[j]
and abs(i - j) <= k
.
-
+
Example 1:
-Input: nums = [1,2,3,1], k = 3
-Output: true
+Input: nums = [1,2,3,1], k = 3
+Output: true
-
Example 2:
-Input: nums = [1,0,1,1], k = 1
-Output: true
+Input: nums = [1,0,1,1], k = 1
+Output: true
-
Example 3:
-Input: nums = [1,2,3,1,2,3], k = 2
-Output: false
+Input: nums = [1,2,3,1,2,3], k = 2
+Output: false
-
-
-
+
+
+Constraints:
+
+
+ 1 <= nums.length <= 105
+ -109 <= nums[i] <= 109
+ 0 <= k <= 105
+
### Related Topics
[[Array](../../tag/array/README.md)]
diff --git a/problems/contains-duplicate-iii/README.md b/problems/contains-duplicate-iii/README.md
index 620dba1a6..03b136785 100644
--- a/problems/contains-duplicate-iii/README.md
+++ b/problems/contains-duplicate-iii/README.md
@@ -11,7 +11,7 @@
## [220. Contains Duplicate III (Medium)](https://leetcode.com/problems/contains-duplicate-iii "存在重复元素 III")
-Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t and the absolute difference between i and j is at most k.
+Given an integer array nums
and two integers k
and t
, return true
if there are two distinct indices i
and j
in the array such that abs(nums[i] - nums[j]) <= t
and abs(i - j) <= k
.
Example 1:
@@ -29,7 +29,7 @@
0 <= nums.length <= 2 * 104
- -231 <= nums[i] <= 231 - 1
+ -231 <= nums[i] <= 231 - 1
0 <= k <= 104
0 <= t <= 231 - 1
diff --git a/problems/contains-duplicate/README.md b/problems/contains-duplicate/README.md
index 1a922e7cf..423ccf0e8 100644
--- a/problems/contains-duplicate/README.md
+++ b/problems/contains-duplicate/README.md
@@ -11,27 +11,26 @@
## [217. Contains Duplicate (Easy)](https://leetcode.com/problems/contains-duplicate "存在重复元素")
-Given an array of integers, find if the array contains any duplicates.
-
-Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.
+Given an integer array nums
, return true
if any value appears at least twice in the array, and return false
if every element is distinct.
+
Example 1:
-
-
-Input: [1,2,3,1]
-Output: true
-
-Example 2:
-
-
-Input: [1,2,3,4]
-Output: false
-
-Example 3:
-
-
-Input: [1,1,1,3,3,4,3,2,4,2]
-Output: true
+Input: nums = [1,2,3,1]
+Output: true
+
Example 2:
+Input: nums = [1,2,3,4]
+Output: false
+
Example 3:
+Input: nums = [1,1,1,3,3,4,3,2,4,2]
+Output: true
+
+
+Constraints:
+
+
+ 1 <= nums.length <= 105
+ -109 <= nums[i] <= 109
+
### Related Topics
[[Array](../../tag/array/README.md)]
diff --git a/problems/corporate-flight-bookings/README.md b/problems/corporate-flight-bookings/README.md
index dac77489e..ecc1f3221 100644
--- a/problems/corporate-flight-bookings/README.md
+++ b/problems/corporate-flight-bookings/README.md
@@ -11,11 +11,11 @@
## [1109. Corporate Flight Bookings (Medium)](https://leetcode.com/problems/corporate-flight-bookings "航班预订统计")
-There are n
flights, and they are labeled from 1
to n
.
+There are n
flights that are labeled from 1
to n
.
-We have a list of flight bookings. The i
-th booking bookings[i] = [i, j, k]
means that we booked k
seats from flights labeled i
to j
inclusive.
+You are given an array of flight bookings bookings
, where bookings[i] = [firsti, lasti, seatsi]
represents a booking for flights firsti
through lasti
(inclusive) with seatsi
seats reserved for each flight in the range.
-Return an array answer
of length n
, representing the number of seats booked on each flight in order of their label.
+Return an array answer
of length n
, where answer[i]
is the total number of seats reserved for flight i
.
Example 1:
@@ -23,15 +23,38 @@
Input: bookings = [[1,2,10],[2,3,20],[2,5,25]], n = 5
Output: [10,55,45,25,25]
+Explanation:
+Flight labels: 1 2 3 4 5
+Booking 1 reserved: 10 10
+Booking 2 reserved: 20 20
+Booking 3 reserved: 25 25 25 25
+Total seats: 10 55 45 25 25
+Hence, answer = [10,55,45,25,25]
+
+
+Example 2:
+
+
+Input: bookings = [[1,2,10],[2,2,15]], n = 2
+Output: [10,25]
+Explanation:
+Flight labels: 1 2
+Booking 1 reserved: 10 10
+Booking 2 reserved: 15
+Total seats: 10 25
+Hence, answer = [10,25]
+
Constraints:
- 1 <= bookings.length <= 20000
- 1 <= bookings[i][0] <= bookings[i][1] <= n <= 20000
- 1 <= bookings[i][2] <= 10000
+ 1 <= n <= 2 * 104
+ 1 <= bookings.length <= 2 * 104
+ bookings[i].length == 3
+ 1 <= firsti <= lasti <= n
+ 1 <= seatsi <= 104
### Related Topics
diff --git a/problems/count-items-matching-a-rule/README.md b/problems/count-items-matching-a-rule/README.md
new file mode 100644
index 000000000..06bc64a51
--- /dev/null
+++ b/problems/count-items-matching-a-rule/README.md
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+[< Previous](../sort-features-by-popularity "Sort Features by Popularity")
+
+[Next >](../closest-dessert-cost "Closest Dessert Cost")
+
+## [1773. Count Items Matching a Rule (Easy)](https://leetcode.com/problems/count-items-matching-a-rule "统计匹配检索规则的物品数量")
+
+You are given an array items
, where each items[i] = [typei, colori, namei]
describes the type, color, and name of the ith
item. You are also given a rule represented by two strings, ruleKey
and ruleValue
.
+
+The ith
item is said to match the rule if one of the following is true:
+
+
+ ruleKey == "type"
and ruleValue == typei
.
+ ruleKey == "color"
and ruleValue == colori
.
+ ruleKey == "name"
and ruleValue == namei
.
+
+
+Return the number of items that match the given rule.
+
+
+Example 1:
+
+
+Input: items = [["phone","blue","pixel"],["computer","silver","lenovo"],["phone","gold","iphone"]], ruleKey = "color", ruleValue = "silver"
+Output: 1
+Explanation: There is only one item matching the given rule, which is ["computer","silver","lenovo"].
+
+
+Example 2:
+
+
+Input: items = [["phone","blue","pixel"],["computer","silver","phone"],["phone","gold","iphone"]], ruleKey = "type", ruleValue = "phone"
+Output: 2
+Explanation: There are only two items matching the given rule, which are ["phone","blue","pixel"] and ["phone","gold","iphone"]. Note that the item ["computer","silver","phone"] does not match.
+
+
+Constraints:
+
+
+ 1 <= items.length <= 104
+ 1 <= typei.length, colori.length, namei.length, ruleValue.length <= 10
+ ruleKey
is equal to either "type"
, "color"
, or "name"
.
+ - All strings consist only of lowercase letters.
+
+
+### Related Topics
+ [[Array](../../tag/array/README.md)]
+ [[String](../../tag/string/README.md)]
+
+### Hints
+
+Hint 1
+Iterate on each item, and check if each one matches the rule according to the statement.
+
diff --git a/problems/count-of-range-sum/README.md b/problems/count-of-range-sum/README.md
index 580e72830..74429591c 100644
--- a/problems/count-of-range-sum/README.md
+++ b/problems/count-of-range-sum/README.md
@@ -11,26 +11,38 @@
## [327. Count of Range Sum (Hard)](https://leetcode.com/problems/count-of-range-sum "区间和的个数")
-Given an integer array nums
, return the number of range sums that lie in [lower, upper]
inclusive.
-Range sum S(i, j)
is defined as the sum of the elements in nums
between indices i
and j
(i
≤ j
), inclusive.
+Given an integer array nums
and two integers lower
and upper
, return the number of range sums that lie in [lower, upper]
inclusive.
-Note:
-A naive algorithm of O(n2) is trivial. You MUST do better than that.
+Range sum S(i, j)
is defined as the sum of the elements in nums
between indices i
and j
inclusive, where i <= j
.
-Example:
+
+Example 1:
+
+
+Input: nums = [-2,5,-1], lower = -2, upper = 2
+Output: 3
+Explanation: The three ranges are: [0,0], [2,2], and [0,2] and their respective sums are: -2, -1, 2.
+
+
+Example 2:
-Input: nums = [-2,5,-1]
, lower = -2
, upper = 2
,
-Output: 3
-Explanation: The three ranges are : [0,0]
, [2,2]
, [0,2]
and their respective sums are: -2, -1, 2
.
+Input: nums = [0], lower = 0, upper = 0
+Output: 1
+
Constraints:
- 0 <= nums.length <= 10^4
+ 1 <= nums.length <= 104
+ -231 <= nums[i] <= 231 - 1
+ -3 * 104 <= lower <= upper <= 3 * 104
+
+Follow up: A naive algorithm of O(n2)
is trivial, Could you do better than that?
+
### Related Topics
[[Sort](../../tag/sort/README.md)]
[[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)]
diff --git a/problems/count-pairs-of-nodes/README.md b/problems/count-pairs-of-nodes/README.md
new file mode 100644
index 000000000..a6cc82f6b
--- /dev/null
+++ b/problems/count-pairs-of-nodes/README.md
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+[< Previous](../sum-of-beauty-of-all-substrings "Sum of Beauty of All Substrings")
+
+[Next >](../grand-slam-titles "Grand Slam Titles")
+
+## [1782. Count Pairs Of Nodes (Hard)](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目")
+
+You are given an undirected graph represented by an integer n
, which is the number of nodes, and edges
, where edges[i] = [ui, vi]
which indicates that there is an undirected edge between ui
and vi
. You are also given an integer array queries
.
+
+The answer to the jth
query is the number of pairs of nodes (a, b)
that satisfy the following conditions:
+
+
+ a < b
+ cnt
is strictly greater than queries[j]
, where cnt
is the number of edges incident to a
or b
.
+
+
+Return an array answers
such that answers.length == queries.length
and answers[j]
is the answer of the jth
query.
+
+Note that there can be repeated edges.
+
+
+Example 1:
+
+
+Input: n = 4, edges = [[1,2],[2,4],[1,3],[2,3],[2,1]], queries = [2,3]
+Output: [6,5]
+Explanation: The number of edges incident to at least one of each pair is shown above.
+
+
+Example 2:
+
+
+Input: n = 5, edges = [[1,5],[1,5],[3,4],[2,5],[1,3],[5,1],[2,3],[2,5]], queries = [1,2,3,4,5]
+Output: [10,10,9,8,6]
+
+
+
+Constraints:
+
+
+ 2 <= n <= 2 * 104
+ 1 <= edges.length <= 105
+ 1 <= ui, vi <= n
+ ui != vi
+ 1 <= queries.length <= 20
+ 0 <= queries[j] < edges.length
+
+
+### Related Topics
+ [[Graph](../../tag/graph/README.md)]
+
+### Hints
+
+Hint 1
+We want to count pairs (x,y) such that degree[x] + degree[y] - occurrences(x,y) > k
+
+
+
+Hint 2
+Think about iterating on x, and counting the number of valid y to pair with x.
+
+
+
+Hint 3
+You can consider at first that the (- occurrences(x,y)) isn't there, or it is 0 at first for all y. Count the valid y this way.
+
+
+
+Hint 4
+Then you can iterate on the neighbors of x, let that neighbor be y, and update occurrences(x,y).
+
+
+
+Hint 5
+When you update occurrences(x,y), the left-hand side decreases. Once it reaches k, then y is not valid for x anymore, so you should decrease the answer by 1.
+
diff --git a/problems/counting-bits/README.md b/problems/counting-bits/README.md
index e8d6a286b..e226ac9f9 100644
--- a/problems/counting-bits/README.md
+++ b/problems/counting-bits/README.md
@@ -11,27 +11,48 @@
## [338. Counting Bits (Medium)](https://leetcode.com/problems/counting-bits "比特位计数")
-Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.
+Given an integer num
, return an array of the number of 1
's in the binary representation of every number in the range [0, num]
.
+
Example 1:
-Input: 2
-Output: [0,1,1]
+Input: num = 2
+Output: [0,1,1]
+Explanation:
+0 --> 0
+1 --> 1
+2 --> 10
+
Example 2:
-Input: 5
-Output: [0,1,1,2,1,2]
+Input: num = 5
+Output: [0,1,1,2,1,2]
+Explanation:
+0 --> 0
+1 --> 1
+2 --> 10
+3 --> 11
+4 --> 100
+5 --> 101
-Follow up:
+
+Constraints:
+
+
+
+
+Follow up:
- - It is very easy to come up with a solution with run time O(n*sizeof(integer)). But can you do it in linear time O(n) /possibly in a single pass?
- - Space complexity should be O(n).
- - Can you do it like a boss? Do it without using any builtin function like __builtin_popcount in c++ or in any other language.
+ - It is very easy to come up with a solution with run time
O(32n)
. Can you do it in linear time O(n)
and possibly in a single pass?
+ - Could you solve it in
O(n)
space complexity?
+ - Can you do it without using any built-in function (i.e., like
__builtin_popcount
in C++)?
### Related Topics
diff --git a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md
index 07a9674a7..ad22327ae 100644
--- a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md
+++ b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md
@@ -9,7 +9,7 @@
[Next >](../count-largest-group "Count Largest Group")
-## [1398. Customers Who Bought Products A and B but Not C (Medium)](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品A和产品B却没有购买产品C的顾客")
+## [1398. Customers Who Bought Products A and B but Not C (Medium)](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品 A 和产品 B 却没有购买产品 C 的顾客")
Table: Customers
diff --git a/problems/deepest-leaves-sum/README.md b/problems/deepest-leaves-sum/README.md
index eebaa5614..bd3d01c5a 100644
--- a/problems/deepest-leaves-sum/README.md
+++ b/problems/deepest-leaves-sum/README.md
@@ -11,23 +11,28 @@
## [1302. Deepest Leaves Sum (Medium)](https://leetcode.com/problems/deepest-leaves-sum "层数最深叶子节点的和")
-Given a binary tree, return the sum of values of its deepest leaves.
+Given the root
of a binary tree, return the sum of values of its deepest leaves.
Example 1:
-
-
-
+
Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8]
Output: 15
+Example 2:
+
+
+Input: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5]
+Output: 19
+
+
Constraints:
- - The number of nodes in the tree is between
1
and 10^4
.
- - The value of nodes is between
1
and 100
.
+ - The number of nodes in the tree is in the range
[1, 104]
.
+ 1 <= Node.val <= 100
### Related Topics
diff --git a/problems/delete-nodes-and-return-forest/README.md b/problems/delete-nodes-and-return-forest/README.md
index 5f6290874..a75659640 100644
--- a/problems/delete-nodes-and-return-forest/README.md
+++ b/problems/delete-nodes-and-return-forest/README.md
@@ -11,22 +11,27 @@
## [1110. Delete Nodes And Return Forest (Medium)](https://leetcode.com/problems/delete-nodes-and-return-forest "删点成林")
-Given the root
of a binary tree, each node in the tree has a distinct value.
+Given the root
of a binary tree, each node in the tree has a distinct value.
-After deleting all nodes with a value in to_delete
, we are left with a forest (a disjoint union of trees).
+After deleting all nodes with a value in to_delete
, we are left with a forest (a disjoint union of trees).
-Return the roots of the trees in the remaining forest. You may return the result in any order.
+Return the roots of the trees in the remaining forest. You may return the result in any order.
Example 1:
-
-
-
+
Input: root = [1,2,3,4,5,6,7], to_delete = [3,5]
Output: [[1,2,null,4],[6],[7]]
+Example 2:
+
+
+Input: root = [1,2,4,null,3], to_delete = [3]
+Output: [[1,2,4]]
+
+
Constraints:
diff --git a/problems/delete-operation-for-two-strings/README.md b/problems/delete-operation-for-two-strings/README.md
index 436c2977a..a10bb31c4 100644
--- a/problems/delete-operation-for-two-strings/README.md
+++ b/problems/delete-operation-for-two-strings/README.md
@@ -11,24 +11,33 @@
## [583. Delete Operation for Two Strings (Medium)](https://leetcode.com/problems/delete-operation-for-two-strings "两个字符串的删除操作")
-
-Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in each step you can delete one character in either string.
-
+Given two strings word1
and word2
, return the minimum number of steps required to make word1
and word2
the same.
+
+In one step, you can delete exactly one character in either string.
+
+
+Example 1:
+
+
+Input: word1 = "sea", word2 = "eat"
+Output: 2
+Explanation: You need one step to make "sea" to "ea" and another step to make "eat" to "ea".
+
+
+Example 2:
-Example 1:
-Input: "sea", "eat"
-Output: 2
-Explanation: You need one step to make "sea" to "ea" and another step to make "eat" to "ea".
+Input: word1 = "leetcode", word2 = "etco"
+Output: 4
-
-
-Note:
-
-- The length of given words won't exceed 500.
-- Characters in given words can only be lower-case letters.
-
-
+
+
+Constraints:
+
+
+ 1 <= word1.length, word2.length <= 500
+ word1
and word2
consist of only lowercase English letters.
+
### Related Topics
[[String](../../tag/string/README.md)]
diff --git a/problems/design-hashmap/README.md b/problems/design-hashmap/README.md
index 1bcfdc4ac..d4234bdf2 100644
--- a/problems/design-hashmap/README.md
+++ b/problems/design-hashmap/README.md
@@ -11,40 +11,50 @@
## [706. Design HashMap (Easy)](https://leetcode.com/problems/design-hashmap "设计哈希映射")
-Design a HashMap without using any built-in hash table libraries.
+Design a HashMap without using any built-in hash table libraries.
-To be specific, your design should include these functions:
+Implement the MyHashMap
class:
- put(key, value)
: Insert a (key, value) pair into the HashMap. If the value already exists in the HashMap, update the value.
- get(key)
: Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key.
- remove(key)
: Remove the mapping for the value key if this map contains the mapping for the key.
+ MyHashMap()
initializes the object with an empty map.
+ void put(int key, int value)
inserts a (key, value)
pair into the HashMap. If the key
already exists in the map, update the corresponding value
.
+ int get(int key)
returns the value
to which the specified key
is mapped, or -1
if this map contains no mapping for the key
.
+ void remove(key)
removes the key
and its corresponding value
if the map contains the mapping for the key
.
-
-Example:
+
+Example 1:
-MyHashMap hashMap = new MyHashMap();
-hashMap.put(1, 1);
-hashMap.put(2, 2);
-hashMap.get(1); // returns 1
-hashMap.get(3); // returns -1 (not found)
-hashMap.put(2, 1); // update the existing value
-hashMap.get(2); // returns 1
-hashMap.remove(2); // remove the mapping for 2
-hashMap.get(2); // returns -1 (not found)
+Input
+["MyHashMap", "put", "put", "get", "get", "put", "get", "remove", "get"]
+[[], [1, 1], [2, 2], [1], [3], [2, 1], [2], [2], [2]]
+Output
+[null, null, null, 1, -1, null, 1, null, -1]
+
+Explanation
+MyHashMap myHashMap = new MyHashMap();
+myHashMap.put(1, 1); // The map is now [[1,1]]
+myHashMap.put(2, 2); // The map is now [[1,1], [2,2]]
+myHashMap.get(1); // return 1, The map is now [[1,1], [2,2]]
+myHashMap.get(3); // return -1 (i.e., not found), The map is now [[1,1], [2,2]]
+myHashMap.put(2, 1); // The map is now [[1,1], [2,1]] (i.e., update the existing value)
+myHashMap.get(2); // return 1, The map is now [[1,1], [2,1]]
+myHashMap.remove(2); // remove the mapping for 2, The map is now [[1,1]]
+myHashMap.get(2); // return -1 (i.e., not found), The map is now [[1,1]]
-
-Note:
+
+Constraints:
- - All keys and values will be in the range of
[0, 1000000]
.
- - The number of operations will be in the range of
[1, 10000]
.
- - Please do not use the built-in HashMap library.
+ 0 <= key, value <= 106
+ - At most
104
calls will be made to put
, get
, and remove
.
+
+Follow up: Please do not use the built-in HashMap library.
+
### Related Topics
[[Design](../../tag/design/README.md)]
[[Hash Table](../../tag/hash-table/README.md)]
diff --git a/problems/design-linked-list/README.md b/problems/design-linked-list/README.md
index a6737c41a..573e5df43 100644
--- a/problems/design-linked-list/README.md
+++ b/problems/design-linked-list/README.md
@@ -11,19 +11,19 @@
## [707. Design Linked List (Medium)](https://leetcode.com/problems/design-linked-list "设计链表")
-Design your implementation of the linked list. You can choose to use a singly or doubly linked list.
-A node in a singly linked list should have two attributes: val
and next
. val
is the value of the current node, and next
is a pointer/reference to the next node.
-If you want to use the doubly linked list, you will need one more attribute prev
to indicate the previous node in the linked list. Assume all nodes in the linked list are 0-indexed.
+Design your implementation of the linked list. You can choose to use a singly or doubly linked list.
+A node in a singly linked list should have two attributes: val
and next
. val
is the value of the current node, and next
is a pointer/reference to the next node.
+If you want to use the doubly linked list, you will need one more attribute prev
to indicate the previous node in the linked list. Assume all nodes in the linked list are 0-indexed.
-Implement the MyLinkedList
class:
+Implement the MyLinkedList
class:
- MyLinkedList()
Initializes the MyLinkedList
object.
- int get(int index)
Get the value of the indexth
node in the linked list. If the index is invalid, return -1
.
- void addAtHead(int val)
Add a node of value val
before the first element of the linked list. After the insertion, the new node will be the first node of the linked list.
- void addAtTail(int val)
Append a node of value val
as the last element of the linked list.
- void addAtIndex(int index, int val)
Add a node of value val
before the indexth
node in the linked list. If index
equals the length of the linked list, the node will be appended to the end of the linked list. If index
is greater than the length, the node will not be inserted.
- void deleteAtIndex(int index)
Delete the indexth
node in the linked list, if the index is valid.
+ MyLinkedList()
Initializes the MyLinkedList
object.
+ int get(int index)
Get the value of the indexth
node in the linked list. If the index is invalid, return -1
.
+ void addAtHead(int val)
Add a node of value val
before the first element of the linked list. After the insertion, the new node will be the first node of the linked list.
+ void addAtTail(int val)
Append a node of value val
as the last element of the linked list.
+ void addAtIndex(int index, int val)
Add a node of value val
before the indexth
node in the linked list. If index
equals the length of the linked list, the node will be appended to the end of the linked list. If index
is greater than the length, the node will not be inserted.
+ void deleteAtIndex(int index)
Delete the indexth
node in the linked list, if the index is valid.
@@ -52,7 +52,7 @@ myLinkedList.get(1); // return 3
0 <= index, val <= 1000
- Please do not use the built-in LinkedList library.
- - At most
2000
calls will be made to get
, addAtHead
, addAtTail
, addAtIndex
and deleteAtIndex
.
+ - At most
2000
calls will be made to get
, addAtHead
, addAtTail
, addAtIndex
and deleteAtIndex
.
### Related Topics
diff --git a/problems/design-most-recently-used-queue/README.md b/problems/design-most-recently-used-queue/README.md
index 8f7116780..636c3c229 100644
--- a/problems/design-most-recently-used-queue/README.md
+++ b/problems/design-most-recently-used-queue/README.md
@@ -9,7 +9,7 @@
[Next >](../recyclable-and-low-fat-products "Recyclable and Low Fat Products")
-## [1756. Design Most Recently Used Queue (Medium)](https://leetcode.com/problems/design-most-recently-used-queue "")
+## [1756. Design Most Recently Used Queue (Medium)](https://leetcode.com/problems/design-most-recently-used-queue "设计最近使用(MRU)队列")
diff --git a/problems/diameter-of-binary-tree/README.md b/problems/diameter-of-binary-tree/README.md
index 9a717ccc8..d4bbeb038 100644
--- a/problems/diameter-of-binary-tree/README.md
+++ b/problems/diameter-of-binary-tree/README.md
@@ -11,28 +11,35 @@
## [543. Diameter of Binary Tree (Easy)](https://leetcode.com/problems/diameter-of-binary-tree "二叉树的直径")
-
-Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.
-
+Given the root
of a binary tree, return the length of the diameter of the tree.
+
+The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root
.
+
+The length of a path between two nodes is represented by the number of edges between them.
+
+
+Example 1:
+
+
+Input: root = [1,2,3,4,5]
+Output: 3
+Explanation: 3is the length of the path [4,2,1,3] or [5,2,1,3].
+
+
+Example 2:
-
-Example:
-Given a binary tree
- 1
- / \
- 2 3
- / \
- 4 5
+Input: root = [1,2]
+Output: 1
-
-
-Return 3, which is the length of the path [4,2,1,3] or [5,2,1,3].
-
-
-Note:
-The length of path between two nodes is represented by the number of edges between them.
-
+
+
+Constraints:
+
+
+ - The number of nodes in the tree is in the range
[1, 104]
.
+ -100 <= Node.val <= 100
+
### Related Topics
[[Tree](../../tag/tree/README.md)]
diff --git a/problems/divide-two-integers/README.md b/problems/divide-two-integers/README.md
index 00b4dfb87..590405578 100644
--- a/problems/divide-two-integers/README.md
+++ b/problems/divide-two-integers/README.md
@@ -17,11 +17,7 @@
The integer division should truncate toward zero, which means losing its fractional part. For example, truncate(8.345) = 8
and truncate(-2.7335) = -2
.
-Note:
-
-
- - Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For this problem, assume that your function returns 231 − 1 when the division result overflows.
-
+Note: Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231, 231 − 1]
. For this problem, assume that your function returns 231 − 1
when the division result overflows.
Example 1:
@@ -58,7 +54,7 @@
Constraints:
- -231 <= dividend, divisor <= 231 - 1
+ -231 <= dividend, divisor <= 231 - 1
divisor != 0
diff --git a/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md b/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md
new file mode 100644
index 000000000..56b3bea92
--- /dev/null
+++ b/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+[< Previous](../closest-dessert-cost "Closest Dessert Cost")
+
+[Next >](../car-fleet-ii "Car Fleet II")
+
+## [1775. Equal Sum Arrays With Minimum Number of Operations (Medium)](https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations "通过最少操作次数使数组的和相等")
+
+You are given two arrays of integers nums1
and nums2
, possibly of different lengths. The values in the arrays are between 1
and 6
, inclusive.
+
+In one operation, you can change any integer's value in any of the arrays to any value between 1
and 6
, inclusive.
+
+Return the minimum number of operations required to make the sum of values in nums1
equal to the sum of values in nums2
. Return -1
if it is not possible to make the sum of the two arrays equal.
+
+
+Example 1:
+
+
+Input: nums1 = [1,2,3,4,5,6], nums2 = [1,1,2,2,2,2]
+Output: 3
+Explanation: You can make the sums of nums1 and nums2 equal with 3 operations. All indices are 0-indexed.
+- Change nums2[0] to 6. nums1 = [1,2,3,4,5,6], nums2 = [6,1,2,2,2,2].
+- Change nums1[5] to 1. nums1 = [1,2,3,4,5,1], nums2 = [6,1,2,2,2,2].
+- Change nums1[2] to 2. nums1 = [1,2,2,4,5,1], nums2 = [6,1,2,2,2,2].
+
+
+Example 2:
+
+
+Input: nums1 = [1,1,1,1,1,1,1], nums2 = [6]
+Output: -1
+Explanation: There is no way to decrease the sum of nums1 or to increase the sum of nums2 to make them equal.
+
+
+Example 3:
+
+
+Input: nums1 = [6,6], nums2 = [1]
+Output: 3
+Explanation: You can make the sums of nums1 and nums2 equal with 3 operations. All indices are 0-indexed.
+- Change nums1[0] to 2. nums1 = [2,6], nums2 = [1].
+- Change nums1[1] to 2. nums1 = [2,2], nums2 = [1].
+- Change nums2[0] to 4. nums1 = [2,2], nums2 = [4].
+
+
+
+Constraints:
+
+
+ 1 <= nums1.length, nums2.length <= 105
+ 1 <= nums1[i], nums2[i] <= 6
+
+
+### Related Topics
+ [[Greedy](../../tag/greedy/README.md)]
+
+### Hints
+
+Hint 1
+Let's note that we want to either decrease the sum of the array with a larger sum or increase the array's sum with the smaller sum.
+
+
+
+Hint 2
+You can maintain the largest increase or decrease you can make in a binary search tree and each time get the maximum one.
+
diff --git a/problems/escape-a-large-maze/README.md b/problems/escape-a-large-maze/README.md
index 0163227ef..8eb48d84f 100644
--- a/problems/escape-a-large-maze/README.md
+++ b/problems/escape-a-large-maze/README.md
@@ -11,11 +11,13 @@
## [1036. Escape a Large Maze (Hard)](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫")
-In a 1 million by 1 million grid, the coordinates of each grid square are (x, y)
.
+There is a 1 million by 1 million grid on an XY-plane, and the coordinates of each grid square are (x, y)
.
-We start at the source
square and want to reach the target
square. Each move, we can walk to a 4-directionally adjacent square in the grid that isn't in the given list of blocked
squares.
+We start at the source = [sx, sy]
square and want to reach the target = [tx, ty]
square. There is also an array of blocked
squares, where each blocked[i] = [xi, yi]
represents a blocked square with coordinates (xi, yi)
.
-Return true
if and only if it is possible to reach the target square through a sequence of moves.
+Each move, we can walk one square north, east, south, or west if the square is not in the array of blocked
squares. We are also not allowed to walk outside of the grid.
+
+Return true
if and only if it is possible to reach the target
square from the source
square through a sequence of valid moves.
Example 1:
@@ -23,7 +25,9 @@
Input: blocked = [[0,1],[1,0]], source = [0,0], target = [0,2]
Output: false
-Explanation: The target square is inaccessible starting from the source square, because we can't walk outside the grid.
+Explanation: The target square is inaccessible starting from the source square because we cannot move.
+We cannot move north or east because those squares are blocked.
+We cannot move south or west because we cannot go outside of the grid.
Example 2:
@@ -31,7 +35,7 @@
Input: blocked = [], source = [0,0], target = [999999,999999]
Output: true
-Explanation: Because there are no blocked cells, it's possible to reach the target square.
+Explanation: Because there are no blocked cells, it is possible to reach the target square.
@@ -40,10 +44,11 @@
0 <= blocked.length <= 200
blocked[i].length == 2
- 0 <= blocked[i][j] < 10^6
+ 0 <= xi, yi < 106
source.length == target.length == 2
- 0 <= source[i][j], target[i][j] < 10^6
+ 0 <= sx, sy, tx, ty < 106
source != target
+ - It is guaranteed that
source
and target
are not blocked.
### Related Topics
diff --git a/problems/evaluate-reverse-polish-notation/README.md b/problems/evaluate-reverse-polish-notation/README.md
index 8517d4438..15146320e 100644
--- a/problems/evaluate-reverse-polish-notation/README.md
+++ b/problems/evaluate-reverse-polish-notation/README.md
@@ -13,19 +13,17 @@
Evaluate the value of an arithmetic expression in Reverse Polish Notation.
-Valid operators are +
, -
, *
, /
. Each operand may be an integer or another expression.
+Valid operators are +
, -
, *
, and /
. Each operand may be an integer or another expression.
-Note:
+Note that division between two integers should truncate toward zero.
-
- - Division between two integers should truncate toward zero.
- - The given RPN expression is always valid. That means the expression would always evaluate to a result and there won't be any divide by zero operation.
-
+It is guaranteed that the given RPN expression is always valid. That means the expression would always evaluate to a result, and there will not be any division by zero operation.
+
Example 1:
-Input: ["2", "1", "+", "3", "*"]
+Input: tokens = ["2","1","+","3","*"]
Output: 9
Explanation: ((2 + 1) * 3) = 9
@@ -33,7 +31,7 @@
Example 2:
-Input: ["4", "13", "5", "/", "+"]
+Input: tokens = ["4","13","5","/","+"]
Output: 6
Explanation: (4 + (13 / 5)) = 6
@@ -41,10 +39,9 @@
Example 3:
-Input: ["10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+"]
+Input: tokens = ["10","6","9","3","+","-11","*","/","*","17","+","5","+"]
Output: 22
-Explanation:
- ((10 * (6 / ((9 + 3) * -11))) + 17) + 5
+Explanation: ((10 * (6 / ((9 + 3) * -11))) + 17) + 5
= ((10 * (6 / (12 * -11))) + 17) + 5
= ((10 * (6 / -132)) + 17) + 5
= ((10 * 0) + 17) + 5
@@ -53,6 +50,14 @@
= 22
+
+Constraints:
+
+
+ 1 <= tokens.length <= 104
+ tokens[i]
is either an operator: "+"
, "-"
, "*"
, or "/"
, or an integer in the range [-200, 200]
.
+
+
### Related Topics
[[Stack](../../tag/stack/README.md)]
diff --git a/problems/excel-sheet-column-number/README.md b/problems/excel-sheet-column-number/README.md
index cc8d7ae28..9700b3966 100644
--- a/problems/excel-sheet-column-number/README.md
+++ b/problems/excel-sheet-column-number/README.md
@@ -11,48 +11,57 @@
## [171. Excel Sheet Column Number (Easy)](https://leetcode.com/problems/excel-sheet-column-number "Excel表列序号")
-Given a column title as appear in an Excel sheet, return its corresponding column number.
+Given a string columnTitle
that represents the column title as appear in an Excel sheet, return its corresponding column number.
For example:
- A -> 1
- B -> 2
- C -> 3
- ...
- Z -> 26
- AA -> 27
- AB -> 28
- ...
+A -> 1
+B -> 2
+C -> 3
+...
+Z -> 26
+AA -> 27
+AB -> 28
+...
+
Example 1:
-Input: "A"
+Input: columnTitle = "A"
Output: 1
Example 2:
-Input: "AB"
+Input: columnTitle = "AB"
Output: 28
Example 3:
-Input: "ZY"
+Input: columnTitle = "ZY"
Output: 701
+
+Example 4:
+
+
+Input: columnTitle = "FXSHRXW"
+Output: 2147483647
+
+
Constraints:
- 1 <= s.length <= 7
- s
consists only of uppercase English letters.
- s
is between "A" and "FXSHRXW".
+ 1 <= columnTitle.length <= 7
+ columnTitle
consists only of uppercase English letters.
+ columnTitle
is in the range ["A", "FXSHRXW"]
.
### Related Topics
diff --git a/problems/excel-sheet-column-title/README.md b/problems/excel-sheet-column-title/README.md
index 9992a826c..afe10387f 100644
--- a/problems/excel-sheet-column-title/README.md
+++ b/problems/excel-sheet-column-title/README.md
@@ -11,42 +11,57 @@
## [168. Excel Sheet Column Title (Easy)](https://leetcode.com/problems/excel-sheet-column-title "Excel表列名称")
-Given a positive integer, return its corresponding column title as appear in an Excel sheet.
+Given an integer columnNumber
, return its corresponding column title as it appears in an Excel sheet.
For example:
- 1 -> A
- 2 -> B
- 3 -> C
- ...
- 26 -> Z
- 27 -> AA
- 28 -> AB
- ...
+A -> 1
+B -> 2
+C -> 3
+...
+Z -> 26
+AA -> 27
+AB -> 28
+...
+
Example 1:
-Input: 1
+Input: columnNumber = 1
Output: "A"
Example 2:
-Input: 28
+Input: columnNumber = 28
Output: "AB"
Example 3:
-Input: 701
+Input: columnNumber = 701
Output: "ZY"
+Example 4:
+
+
+Input: columnNumber = 2147483647
+Output: "FXSHRXW"
+
+
+
+Constraints:
+
+
+ 1 <= columnNumber <= 231 - 1
+
+
### Related Topics
[[Math](../../tag/math/README.md)]
diff --git a/problems/find-minimum-in-rotated-sorted-array-ii/README.md b/problems/find-minimum-in-rotated-sorted-array-ii/README.md
index 322b4d2d7..97759c93e 100644
--- a/problems/find-minimum-in-rotated-sorted-array-ii/README.md
+++ b/problems/find-minimum-in-rotated-sorted-array-ii/README.md
@@ -11,33 +11,38 @@
## [154. Find Minimum in Rotated Sorted Array II (Hard)](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii "寻找旋转排序数组中的最小值 II")
-Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
+Suppose an array of length n
sorted in ascending order is rotated between 1
and n
times. For example, the array nums = [0,1,4,4,5,6,7]
might become:
-(i.e., [0,1,2,4,5,6,7]
might become [4,5,6,7,0,1,2]
).
+
+ [4,5,6,7,0,1,4]
if it was rotated 4
times.
+ [0,1,4,4,5,6,7]
if it was rotated 7
times.
+
-Find the minimum element.
+Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]]
1 time results in the array [a[n-1], a[0], a[1], a[2], ..., a[n-2]]
.
-The array may contain duplicates.
+Given the sorted rotated array nums
that may contain duplicates, return the minimum element of this array.
+
Example 1:
-
-
-Input: [1,3,5]
-Output: 1
-
-Example 2:
-
-
-Input: [2,2,2,0,1]
-Output: 0
-
-Note:
+Input: nums = [1,3,5]
+Output: 1
+
Example 2:
+Input: nums = [2,2,2,0,1]
+Output: 0
+
+
+Constraints:
- - This is a follow up problem to Find Minimum in Rotated Sorted Array.
- - Would allow duplicates affect the run-time complexity? How and why?
+ n == nums.length
+ 1 <= n <= 5000
+ -5000 <= nums[i] <= 5000
+ nums
is sorted and rotated between 1
and n
times.
+
+Follow up: This is the same as Find Minimum in Rotated Sorted Array but with duplicates. Would allow duplicates affect the run-time complexity? How and why?
+
### Related Topics
[[Array](../../tag/array/README.md)]
[[Binary Search](../../tag/binary-search/README.md)]
diff --git a/problems/find-minimum-in-rotated-sorted-array/README.md b/problems/find-minimum-in-rotated-sorted-array/README.md
index b7a6c720e..aade6faf9 100644
--- a/problems/find-minimum-in-rotated-sorted-array/README.md
+++ b/problems/find-minimum-in-rotated-sorted-array/README.md
@@ -20,7 +20,7 @@
Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]]
1 time results in the array [a[n-1], a[0], a[1], a[2], ..., a[n-2]]
.
-Given the sorted rotated array nums
, return the minimum element of this array.
+Given the sorted rotated array nums
of unique elements, return the minimum element of this array.
Example 1:
diff --git a/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md
new file mode 100644
index 000000000..870808615
--- /dev/null
+++ b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+[< Previous](../shortest-path-in-a-hidden-grid "Shortest Path in a Hidden Grid")
+
+[Next >](../check-if-number-is-a-sum-of-powers-of-three "Check if Number is a Sum of Powers of Three")
+
+## [1779. Find Nearest Point That Has the Same X or Y Coordinate (Easy)](https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate "找到最近的有相同 X 或 Y 坐标的点")
+
+You are given two integers, x
and y
, which represent your current location on a Cartesian grid: (x, y)
. You are also given an array points
where each points[i] = [ai, bi]
represents that a point exists at (ai, bi)
. A point is valid if it shares the same x-coordinate or the same y-coordinate as your location.
+
+Return the index (0-indexed) of the valid point with the smallest Manhattan distance from your current location. If there are multiple, return the valid point with the smallest index. If there are no valid points, return -1
.
+
+The Manhattan distance between two points (x1, y1)
and (x2, y2)
is abs(x1 - x2) + abs(y1 - y2)
.
+
+
+Example 1:
+
+
+Input: x = 3, y = 4, points = [[1,2],[3,1],[2,4],[2,3],[4,4]]
+Output: 2
+Explanation: Of all the points, only [3,1], [2,4] and [4,4] are valid. Of the valid points, [2,4] and [4,4] have the smallest Manhattan distance from your current location, with a distance of 1. [2,4] has the smallest index, so return 2.
+
+Example 2:
+
+
+Input: x = 3, y = 4, points = [[3,4]]
+Output: 0
+Explanation: The answer is allowed to be on the same location as your current location.
+
+Example 3:
+
+
+Input: x = 3, y = 4, points = [[2,3]]
+Output: -1
+Explanation: There are no valid points.
+
+
+Constraints:
+
+
+ 1 <= points.length <= 104
+ points[i].length == 2
+ 1 <= x, y, ai, bi <= 104
+
+
+### Related Topics
+ [[Array](../../tag/array/README.md)]
+
+### Hints
+
+Hint 1
+Iterate through each point, and keep track of the current point with the smallest Manhattan distance from your current location.
+
diff --git a/problems/find-pivot-index/README.md b/problems/find-pivot-index/README.md
index 3ba48f5f0..9774506f1 100644
--- a/problems/find-pivot-index/README.md
+++ b/problems/find-pivot-index/README.md
@@ -9,7 +9,7 @@
[Next >](../split-linked-list-in-parts "Split Linked List in Parts")
-## [724. Find Pivot Index (Easy)](https://leetcode.com/problems/find-pivot-index "寻找数组的中心索引")
+## [724. Find Pivot Index (Easy)](https://leetcode.com/problems/find-pivot-index "寻找数组的中心下标")
Given an array of integers nums
, calculate the pivot index of this array.
diff --git a/problems/flip-columns-for-maximum-number-of-equal-rows/README.md b/problems/flip-columns-for-maximum-number-of-equal-rows/README.md
index eb25ef95a..836d48166 100644
--- a/problems/flip-columns-for-maximum-number-of-equal-rows/README.md
+++ b/problems/flip-columns-for-maximum-number-of-equal-rows/README.md
@@ -11,55 +11,46 @@
## [1072. Flip Columns For Maximum Number of Equal Rows (Medium)](https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows "按列翻转得到最大值等行数")
-Given a matrix
consisting of 0s and 1s, we may choose any number of columns in the matrix and flip every cell in that column. Flipping a cell changes the value of that cell from 0 to 1 or from 1 to 0.
+You are given an m x n
binary matrix matrix
.
-Return the maximum number of rows that have all values equal after some number of flips.
+You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from 0
to 1
or vice versa).
-
-
-
-
+Return the maximum number of rows that have all values equal after some number of flips.
-
+
Example 1:
-Input: [[0,1],[1,1]]
-Output: 1
-Explanation: After flipping no values, 1 row has all values equal.
+Input: matrix = [[0,1],[1,1]]
+Output: 1
+Explanation: After flipping no values, 1 row has all values equal.
-
Example 2:
-Input: [[0,1],[1,0]]
-Output: 2
-Explanation: After flipping values in the first column, both rows have equal values.
+Input: matrix = [[0,1],[1,0]]
+Output: 2
+Explanation: After flipping values in the first column, both rows have equal values.
-
Example 3:
-Input: [[0,0,0],[0,0,1],[1,1,0]]
-Output: 2
-Explanation: After flipping values in the first two columns, the last two rows have equal values.
+Input: matrix = [[0,0,0],[0,0,1],[1,1,0]]
+Output: 2
+Explanation: After flipping values in the first two columns, the last two rows have equal values.
-
-
Note:
-
-
- 1 <= matrix.length <= 300
- 1 <= matrix[i].length <= 300
- - All
matrix[i].length
's are equal
- matrix[i][j]
is 0
or 1
-
-
-
-
+Constraints:
+
+
+ m == matrix.length
+ n == matrix[i].length
+ 1 <= m, n <= 300
+ matrix[i][j]
is either 0
or 1
.
+
### Related Topics
[[Hash Table](../../tag/hash-table/README.md)]
diff --git a/problems/flipping-an-image/README.md b/problems/flipping-an-image/README.md
index a15791ada..5bf0dcf57 100644
--- a/problems/flipping-an-image/README.md
+++ b/problems/flipping-an-image/README.md
@@ -11,17 +11,26 @@
## [832. Flipping an Image (Easy)](https://leetcode.com/problems/flipping-an-image "翻转图像")
-Given a binary matrix A
, we want to flip the image horizontally, then invert it, and return the resulting image.
+Given an n x n
binary matrix image
, flip the image horizontally, then invert it, and return the resulting image.
-To flip an image horizontally means that each row of the image is reversed. For example, flipping [1, 1, 0]
horizontally results in [0, 1, 1]
.
+To flip an image horizontally means that each row of the image is reversed.
-To invert an image means that each 0
is replaced by 1
, and each 1
is replaced by 0
. For example, inverting [0, 1, 1]
results in [1, 0, 0]
.
+
+ - For example, flipping
[1,1,0]
horizontally results in [0,1,1]
.
+
+
+To invert an image means that each 0
is replaced by 1
, and each 1
is replaced by 0
.
+
+
+ - For example, inverting
[0,1,1]
results in [1,0,0]
.
+
+
Example 1:
-Input: [[1,1,0],[1,0,1],[0,0,0]]
-Output: [[1,0,0],[0,1,0],[1,1,1]]
+Input: image = [[1,1,0],[1,0,1],[0,0,0]]
+Output: [[1,0,0],[0,1,0],[1,1,1]]
Explanation: First reverse each row: [[0,1,1],[1,0,1],[0,0,0]].
Then, invert the image: [[1,0,0],[0,1,0],[1,1,1]]
@@ -29,17 +38,20 @@ Then, invert the image: [[1,0,0],[0,1,0],[1,1,1]]
Example 2:
-Input: [[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]]
-Output: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]
+Input: image = [[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]]
+Output: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]
Explanation: First reverse each row: [[0,0,1,1],[1,0,0,1],[1,1,1,0],[0,1,0,1]].
Then invert the image: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]
-Notes:
+
+Constraints:
- 1 <= A.length = A[0].length <= 20
- 0 <= A[i][j] <= 1
+ n == image.length
+ n == image[i].length
+ 1 <= n <= 20
+ images[i][j]
is either 0
or 1
.
### Related Topics
diff --git a/problems/grand-slam-titles/README.md b/problems/grand-slam-titles/README.md
new file mode 100644
index 000000000..cb4e14e5b
--- /dev/null
+++ b/problems/grand-slam-titles/README.md
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+[< Previous](../count-pairs-of-nodes "Count Pairs Of Nodes")
+
+[Next >](../check-if-binary-string-has-at-most-one-segment-of-ones "Check if Binary String Has at Most One Segment of Ones")
+
+## [1783. Grand Slam Titles (Medium)](https://leetcode.com/problems/grand-slam-titles "")
+
+
diff --git a/problems/grand-slam-titles/mysql_schemas.sql b/problems/grand-slam-titles/mysql_schemas.sql
new file mode 100644
index 000000000..dd19af729
--- /dev/null
+++ b/problems/grand-slam-titles/mysql_schemas.sql
@@ -0,0 +1,10 @@
+Create table If Not Exists Players (player_id int, player_name varchar(20));
+Create table If Not Exists Championships (year int, Wimbledon int, Fr_open int, US_open int, Au_open int);
+Truncate table Players;
+insert into Players (player_id, player_name) values ('1', 'Nadal');
+insert into Players (player_id, player_name) values ('2', 'Federer');
+insert into Players (player_id, player_name) values ('3', 'Novak');
+Truncate table Championships;
+insert into Championships (year, Wimbledon, Fr_open, US_open, Au_open) values ('2018', '1', '1', '1', '1');
+insert into Championships (year, Wimbledon, Fr_open, US_open, Au_open) values ('2019', '1', '1', '2', '2');
+insert into Championships (year, Wimbledon, Fr_open, US_open, Au_open) values ('2020', '2', '1', '2', '2');
diff --git a/problems/h-index-ii/README.md b/problems/h-index-ii/README.md
index d501faf00..791166a18 100644
--- a/problems/h-index-ii/README.md
+++ b/problems/h-index-ii/README.md
@@ -11,31 +11,42 @@
## [275. H-Index II (Medium)](https://leetcode.com/problems/h-index-ii "H 指数 II")
-Given an array of citations sorted in ascending order (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.
+Given an array of integers citations
where citations[i]
is the number of citations a researcher received for their ith
paper and citations
is sorted in an ascending order, return compute the researcher's h
-index.
-According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than h citations each."
+According to the definition of h-index on Wikipedia: A scientist has an index h
if h
of their n
papers have at least h
citations each, and the other n − h
papers have no more than h
citations each.
-Example:
+If there are several possible values for h
, the maximum one is taken as the h
-index.
+
+
+Example 1:
-Input: citations = [0,1,3,5,6]
-Output: 3
-Explanation: [0,1,3,5,6]
means the researcher has 5
papers in total and each of them had
- received 0, 1, 3, 5, 6
citations respectively.
- Since the researcher has 3
papers with at least 3
citations each and the remaining
- two with no more than 3
citations each, her h-index is 3
.
+Input: citations = [0,1,3,5,6]
+Output: 3
+Explanation: [0,1,3,5,6] means the researcher has 5 papers in total and each of them had received 0, 1, 3, 5, 6 citations respectively.
+Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, their h-index is 3.
+
-Note:
+Example 2:
-If there are several possible values for h, the maximum one is taken as the h-index.
+
+Input: citations = [1,2,100]
+Output: 0
+
-Follow up:
+
+Constraints:
- - This is a follow up problem to H-Index, where
citations
is now guaranteed to be sorted in ascending order.
- - Could you solve it in logarithmic time complexity?
+ n == citations.length
+ 1 <= n <= 105
+ 0 <= citations[i] <= 1000
+ citations
is sorted in ascending order.
+
+Follow up: Could you solve it in logarithmic time complexity?
+
### Related Topics
[[Binary Search](../../tag/binary-search/README.md)]
diff --git a/problems/h-index/README.md b/problems/h-index/README.md
index 734b667b4..fde6daec3 100644
--- a/problems/h-index/README.md
+++ b/problems/h-index/README.md
@@ -11,21 +11,37 @@
## [274. H-Index (Medium)](https://leetcode.com/problems/h-index "H 指数")
-Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.
+Given an array of integers citations
where citations[i]
is the number of citations a researcher received for their ith
paper, return compute the researcher's h
-index.
-According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than h citations each."
+According to the definition of h-index on Wikipedia: A scientist has an index h
if h
of their n
papers have at least h
citations each, and the other n − h
papers have no more than h
citations each.
-Example:
+If there are several possible values for h
, the maximum one is taken as the h
-index.
+
+
+Example 1:
+
+
+Input: citations = [3,0,6,1,5]
+Output: 3
+Explanation: [3,0,6,1,5] means the researcher has 5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively.
+Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, their h-index is 3.
+
+
+Example 2:
-Input: citations = [3,0,6,1,5]
-Output: 3
-Explanation: [3,0,6,1,5]
means the researcher has 5
papers in total and each of them had
- received 3, 0, 6, 1, 5
citations respectively.
- Since the researcher has 3
papers with at least 3
citations each and the remaining
- two with no more than 3
citations each, her h-index is 3
.
-
-Note: If there are several possible values for h, the maximum one is taken as the h-index.
+Input: citations = [1,3,1]
+Output: 1
+
+
+
+Constraints:
+
+
+ n == citations.length
+ 1 <= n <= 5000
+ 0 <= citations[i] <= 1000
+
### Related Topics
[[Sort](../../tag/sort/README.md)]
diff --git a/problems/house-robber-ii/README.md b/problems/house-robber-ii/README.md
index 08afb0147..815191ce6 100644
--- a/problems/house-robber-ii/README.md
+++ b/problems/house-robber-ii/README.md
@@ -54,7 +54,7 @@ Total amount you can rob = 1 + 3 = 4.
### Similar Questions
1. [House Robber](../house-robber) (Medium)
1. [Paint House](../paint-house) (Medium)
- 1. [Paint Fence](../paint-fence) (Easy)
+ 1. [Paint Fence](../paint-fence) (Medium)
1. [House Robber III](../house-robber-iii) (Medium)
1. [Non-negative Integers without Consecutive Ones](../non-negative-integers-without-consecutive-ones) (Hard)
1. [Coin Path](../coin-path) (Hard)
diff --git a/problems/house-robber-iii/README.md b/problems/house-robber-iii/README.md
index 67ac3eb50..32cd66c87 100644
--- a/problems/house-robber-iii/README.md
+++ b/problems/house-robber-iii/README.md
@@ -11,42 +11,41 @@
## [337. House Robber III (Medium)](https://leetcode.com/problems/house-robber-iii "打家劫舍 III")
-The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms a binary tree". It will automatically contact the police if two directly-linked houses were broken into on the same night.
+The thief has found himself a new place for his thievery again. There is only one entrance to this area, called root
.
-Determine the maximum amount of money the thief can rob tonight without alerting the police.
+Besides the root
, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will automatically contact the police if two directly-linked houses were broken into on the same night.
-Example 1:
+Given the root
of the binary tree, return the maximum amount of money the thief can rob without alerting the police.
+
+Example 1:
+
-Input: [3,2,3,null,3,null,1]
-
- 3
- / \
- 2 3
- \ \
- 3 1
-
-Output: 7
-Explanation: Maximum amount of money the thief can rob = 3 + 3 + 1 = 7.
-
-Example 2:
+Input: root = [3,2,3,null,3,null,1]
+Output: 7
+Explanation: Maximum amount of money the thief can rob = 3 + 3 + 1 = 7.
+
+Example 2:
+
-Input: [3,4,5,1,3,null,1]
-
- 3
- / \
- 4 5
- / \ \
- 1 3 1
-
+Input: root = [3,4,5,1,3,null,1]
Output: 9
-Explanation: Maximum amount of money the thief can rob = 4 + 5 = 9.
+Explanation: Maximum amount of money the thief can rob = 4 + 5 = 9.
+
+Constraints:
+
+
+ - The number of nodes in the tree is in the range
[1, 104]
.
+ 0 <= Node.val <= 104
+
+
### Related Topics
[[Tree](../../tag/tree/README.md)]
[[Depth-first Search](../../tag/depth-first-search/README.md)]
+ [[Dynamic Programming](../../tag/dynamic-programming/README.md)]
### Similar Questions
1. [House Robber](../house-robber) (Medium)
diff --git a/problems/house-robber/README.md b/problems/house-robber/README.md
index 004111de6..c44764161 100644
--- a/problems/house-robber/README.md
+++ b/problems/house-robber/README.md
@@ -11,9 +11,9 @@
## [198. House Robber (Medium)](https://leetcode.com/problems/house-robber "打家劫舍")
-You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.
+You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and it will automatically contact the police if two adjacent houses were broken into on the same night.
-Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.
+Given an integer array nums
representing the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police.
Example 1:
@@ -22,7 +22,7 @@
Input: nums = [1,2,3,1]
Output: 4
Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).
- Total amount you can rob = 1 + 3 = 4.
+Total amount you can rob = 1 + 3 = 4.
Example 2:
@@ -31,14 +31,14 @@
Input: nums = [2,7,9,3,1]
Output: 12
Explanation: Rob house 1 (money = 2), rob house 3 (money = 9) and rob house 5 (money = 1).
- Total amount you can rob = 2 + 9 + 1 = 12.
+Total amount you can rob = 2 + 9 + 1 = 12.
Constraints:
- 0 <= nums.length <= 100
+ 1 <= nums.length <= 100
0 <= nums[i] <= 400
@@ -49,7 +49,7 @@
1. [Maximum Product Subarray](../maximum-product-subarray) (Medium)
1. [House Robber II](../house-robber-ii) (Medium)
1. [Paint House](../paint-house) (Medium)
- 1. [Paint Fence](../paint-fence) (Easy)
+ 1. [Paint Fence](../paint-fence) (Medium)
1. [House Robber III](../house-robber-iii) (Medium)
1. [Non-negative Integers without Consecutive Ones](../non-negative-integers-without-consecutive-ones) (Hard)
1. [Coin Path](../coin-path) (Hard)
diff --git a/problems/implement-trie-prefix-tree/README.md b/problems/implement-trie-prefix-tree/README.md
index 00bcce42e..d740026d7 100644
--- a/problems/implement-trie-prefix-tree/README.md
+++ b/problems/implement-trie-prefix-tree/README.md
@@ -11,26 +11,44 @@
## [208. Implement Trie (Prefix Tree) (Medium)](https://leetcode.com/problems/implement-trie-prefix-tree "实现 Trie (前缀树)")
-Implement a trie with insert
, search
, and startsWith
methods.
+Trie (we pronounce "try") or prefix tree is a tree data structure used to retrieve a key in a strings dataset. There are various applications of this very efficient data structure, such as autocomplete and spellchecker.
-Example:
+Implement the Trie class:
+
+
+ Trie()
initializes the trie object.
+ void insert(String word)
inserts the string word
to the trie.
+ boolean search(String word)
returns true
if the string word
is in the trie (i.e., was inserted before), and false
otherwise.
+ boolean startsWith(String prefix)
returns true
if there is a previously inserted string word
that has the prefix prefix
, and false
otherwise.
+
+
+
+Example 1:
-Trie trie = new Trie();
+Input
+["Trie", "insert", "search", "search", "startsWith", "insert", "search"]
+[[], ["apple"], ["apple"], ["app"], ["app"], ["app"], ["app"]]
+Output
+[null, null, true, false, true, null, true]
+Explanation
+Trie trie = new Trie();
trie.insert("apple");
-trie.search("apple"); // returns true
-trie.search("app"); // returns false
-trie.startsWith("app"); // returns true
-trie.insert("app");
-trie.search("app"); // returns true
+trie.search("apple"); // return True
+trie.search("app"); // return False
+trie.startsWith("app"); // return True
+trie.insert("app");
+trie.search("app"); // return True
-Note:
+
+Constraints:
- - You may assume that all inputs are consist of lowercase letters
a-z
.
- - All inputs are guaranteed to be non-empty strings.
+ 1 <= word.length, prefix.length <= 2000
+ word
and prefix
consist of lowercase English letters.
+ - At most
3 * 104
calls will be made to insert
, search
, and startsWith
.
### Related Topics
diff --git a/problems/inorder-successor-in-bst/README.md b/problems/inorder-successor-in-bst/README.md
index 649abbec5..11fc3ef36 100644
--- a/problems/inorder-successor-in-bst/README.md
+++ b/problems/inorder-successor-in-bst/README.md
@@ -9,7 +9,7 @@
[Next >](../walls-and-gates "Walls and Gates")
-## [285. Inorder Successor in BST (Medium)](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的顺序后继")
+## [285. Inorder Successor in BST (Medium)](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的中序后继")
Given a binary search tree and a node in it, find the in-order successor of that node in the BST.
diff --git a/problems/insertion-sort-list/README.md b/problems/insertion-sort-list/README.md
index e91075c57..2de949f40 100644
--- a/problems/insertion-sort-list/README.md
+++ b/problems/insertion-sort-list/README.md
@@ -11,42 +11,41 @@
## [147. Insertion Sort List (Medium)](https://leetcode.com/problems/insertion-sort-list "对链表进行插入排序")
-Sort a linked list using insertion sort.
+Given the head
of a singly linked list, sort the list using insertion sort, and return the sorted list's head.
-
-
-
-
-A graphical example of insertion sort. The partial sorted list (black) initially contains only the first element in the list.
-With each iteration one element (red) is removed from the input data and inserted in-place into the sorted list
-
+The steps of the insertion sort algorithm:
-
-
-Algorithm of Insertion Sort:
-
-
- - Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list.
- - At each iteration, insertion sort removes one element from the input data, finds the location it belongs within the sorted list, and inserts it there.
+ - Insertion sort iterates, consuming one input element each repetition and growing a sorted output list.
+ - At each iteration, insertion sort removes one element from the input data, finds the location it belongs within the sorted list and inserts it there.
- It repeats until no input elements remain.
-
-Example 1:
-
+The following is a graphical example of the insertion sort algorithm. The partially sorted list (black) initially contains only the first element in the list. One element (red) is removed from the input data and inserted in-place into the sorted list with each iteration.
+
+
+Example 1:
+
-Input: 4->2->1->3
-Output: 1->2->3->4
+Input: head = [4,2,1,3]
+Output: [1,2,3,4]
Example 2:
-
+
-Input: -1->5->3->4->0
-Output: -1->0->3->4->5
+Input: head = [-1,5,3,4,0]
+Output: [-1,0,3,4,5]
+
+Constraints:
+
+
+ - The number of nodes in the list is in the range
[1, 5000]
.
+ -5000 <= Node.val <= 5000
+
+
### Related Topics
[[Sort](../../tag/sort/README.md)]
[[Linked List](../../tag/linked-list/README.md)]
diff --git a/problems/intersection-of-two-linked-lists/README.md b/problems/intersection-of-two-linked-lists/README.md
index 3e7090f99..35ee928a9 100644
--- a/problems/intersection-of-two-linked-lists/README.md
+++ b/problems/intersection-of-two-linked-lists/README.md
@@ -11,58 +11,59 @@
## [160. Intersection of Two Linked Lists (Easy)](https://leetcode.com/problems/intersection-of-two-linked-lists "相交链表")
-Write a program to find the node at which the intersection of two singly linked lists begins.
+Given the heads of two singly linked-lists headA
and headB
, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null
.
-For example, the following two linked lists:
-
+For example, the following two linked lists begin to intersect at node c1
:
+
+It is guaranteed that there are no cycles anywhere in the entire linked structure.
-begin to intersect at node c1.
+Note that the linked lists must retain their original structure after the function returns.
-
Example 1:
-
-
+
-Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5], skipA = 2, skipB = 3
-Output: Reference of the node with value = 8
-Input Explanation: The intersected node's value is 8 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,6,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B.
-
-
+Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5], skipA = 2, skipB = 3
+Output: Intersected at '8'
+Explanation: The intersected node's value is 8 (note that this must not be 0 if the two lists intersect).
+From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,6,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B.
+
Example 2:
-
-
+
-Input: intersectVal = 2, listA = [1,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1
-Output: Reference of the node with value = 2
-Input Explanation: The intersected node's value is 2 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [1,9,1,2,4]. From the head of B, it reads as [3,2,4]. There are 3 nodes before the intersected node in A; There are 1 node before the intersected node in B.
+Input: intersectVal = 2, listA = [1,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1
+Output: Intersected at '2'
+Explanation: The intersected node's value is 2 (note that this must not be 0 if the two lists intersect).
+From the head of A, it reads as [1,9,1,2,4]. From the head of B, it reads as [3,2,4]. There are 3 nodes before the intersected node in A; There are 1 node before the intersected node in B.
-
-
Example 3:
-
-
+
-Input: intersectVal = 0, listA = [2,6,4], listB = [1,5], skipA = 3, skipB = 2
-Output: null
-Input Explanation: From the head of A, it reads as [2,6,4]. From the head of B, it reads as [1,5]. Since the two lists do not intersect, intersectVal must be 0, while skipA and skipB can be arbitrary values.
-Explanation: The two lists do not intersect, so return null.
+Input: intersectVal = 0, listA = [2,6,4], listB = [1,5], skipA = 3, skipB = 2
+Output: No intersection
+Explanation: From the head of A, it reads as [2,6,4]. From the head of B, it reads as [1,5]. Since the two lists do not intersect, intersectVal must be 0, while skipA and skipB can be arbitrary values.
+Explanation: The two lists do not intersect, so return null.
-
-Notes:
+Constraints:
- - If the two linked lists have no intersection at all, return
null
.
- - The linked lists must retain their original structure after the function returns.
- - You may assume there are no cycles anywhere in the entire linked structure.
- - Each value on each linked list is in the range
[1, 10^9]
.
- - Your code should preferably run in O(n) time and use only O(1) memory.
+ - The number of nodes of
listA
is in the m
.
+ - The number of nodes of
listB
is in the n
.
+ 1 <= m, n <= 3 * 104
+ 1 <= Node.val <= 105
+ 1 <= skipA <= m
+ 1 <= skipB <= n
+ intersectVal
is 0
if listA
and listB
do not intersect.
+ intersectVal == listA[skipA + 1] == listB[skipB + 1]
if listA
and listB
intersect.
+
+Follow up: Could you write a solution that runs in O(n)
time and use only O(1)
memory?
+
### Related Topics
[[Linked List](../../tag/linked-list/README.md)]
diff --git a/problems/jump-game-ii/README.md b/problems/jump-game-ii/README.md
index 17fa35682..ac0e0385c 100644
--- a/problems/jump-game-ii/README.md
+++ b/problems/jump-game-ii/README.md
@@ -9,7 +9,7 @@
[Next >](../permutations "Permutations")
-## [45. Jump Game II (Hard)](https://leetcode.com/problems/jump-game-ii "跳跃游戏 II")
+## [45. Jump Game II (Medium)](https://leetcode.com/problems/jump-game-ii "跳跃游戏 II")
Given an array of non-negative integers nums
, you are initially positioned at the first index of the array.
@@ -39,7 +39,7 @@
Constraints:
- 1 <= nums.length <= 3 * 104
+ 1 <= nums.length <= 1000
0 <= nums[i] <= 105
diff --git a/problems/jump-game/README.md b/problems/jump-game/README.md
index b0d1ac8b7..391a3b615 100644
--- a/problems/jump-game/README.md
+++ b/problems/jump-game/README.md
@@ -47,4 +47,4 @@
[[Array](../../tag/array/README.md)]
### Similar Questions
- 1. [Jump Game II](../jump-game-ii) (Hard)
+ 1. [Jump Game II](../jump-game-ii) (Medium)
diff --git a/problems/k-closest-points-to-origin/README.md b/problems/k-closest-points-to-origin/README.md
index 4ae0f6d86..4f273231d 100644
--- a/problems/k-closest-points-to-origin/README.md
+++ b/problems/k-closest-points-to-origin/README.md
@@ -11,47 +11,40 @@
## [973. K Closest Points to Origin (Medium)](https://leetcode.com/problems/k-closest-points-to-origin "最接近原点的 K 个点")
-We have a list of points
on the plane. Find the K
closest points to the origin (0, 0)
.
+Given an array of points
where points[i] = [xi, yi]
represents a point on the X-Y plane and an integer k
, return the k
closest points to the origin (0, 0)
.
-(Here, the distance between two points on a plane is the Euclidean distance.)
+The distance between two points on the X-Y plane is the Euclidean distance (i.e, √(x1 - x2)2 + (y1 - y2)2
).
-You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in.)
+You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in).
-
-
Example 1:
-
+
-Input: points = [[1,3],[-2,2]], K = 1
-Output: [[-2,2]]
-Explanation:
+Input: points = [[1,3],[-2,2]], k = 1
+Output: [[-2,2]]
+Explanation:
The distance between (1, 3) and the origin is sqrt(10).
The distance between (-2, 2) and the origin is sqrt(8).
Since sqrt(8) < sqrt(10), (-2, 2) is closer to the origin.
-We only want the closest K = 1 points from the origin, so the answer is just [[-2,2]].
+We only want the closest k = 1 points from the origin, so the answer is just [[-2,2]].
-
Example 2:
-Input: points = [[3,3],[5,-1],[-2,4]], K = 2
-Output: [[3,3],[-2,4]]
-(The answer [[-2,4],[3,3]] would also be accepted.)
+Input: points = [[3,3],[5,-1],[-2,4]], k = 2
+Output: [[3,3],[-2,4]]
+Explanation: The answer [[-2,4],[3,3]] would also be accepted.
+
Constraints:
-
Note:
-
-
- 1 <= K <= points.length <= 10000
- -10000 < points[i][0] < 10000
- -10000 < points[i][1] < 10000
-
-
-
+
+ 1 <= k <= points.length <= 104
+ -104 < xi, yi < 104
+
### Related Topics
[[Heap](../../tag/heap/README.md)]
diff --git a/problems/kill-process/README.md b/problems/kill-process/README.md
index 3df553616..fc8bf6ef2 100644
--- a/problems/kill-process/README.md
+++ b/problems/kill-process/README.md
@@ -9,7 +9,7 @@
[Next >](../delete-operation-for-two-strings "Delete Operation for Two Strings")
-## [582. Kill Process (Medium)](https://leetcode.com/problems/kill-process "杀死进程")
+## [582. Kill Process (Medium)](https://leetcode.com/problems/kill-process "杀掉进程")
Given n processes, each process has a unique PID (process id) and its PPID (parent process id).
diff --git a/problems/koko-eating-bananas/README.md b/problems/koko-eating-bananas/README.md
index dcef83a39..f9bf79576 100644
--- a/problems/koko-eating-bananas/README.md
+++ b/problems/koko-eating-bananas/README.md
@@ -11,32 +11,43 @@
## [875. Koko Eating Bananas (Medium)](https://leetcode.com/problems/koko-eating-bananas "爱吃香蕉的珂珂")
-
Koko loves to eat bananas. There are N
piles of bananas, the i
-th pile has piles[i]
bananas. The guards have gone and will come back in H
hours.
+Koko loves to eat bananas. There are n
piles of bananas, the ith
pile has piles[i]
bananas. The guards have gone and will come back in h
hours.
-Koko can decide her bananas-per-hour eating speed of K
. Each hour, she chooses some pile of bananas, and eats K bananas from that pile. If the pile has less than K
bananas, she eats all of them instead, and won't eat any more bananas during this hour.
+Koko can decide her bananas-per-hour eating speed of k
. Each hour, she chooses some pile of bananas and eats k
bananas from that pile. If the pile has less than k
bananas, she eats all of them instead and will not eat any more bananas during this hour.
-Koko likes to eat slowly, but still wants to finish eating all the bananas before the guards come back.
+Koko likes to eat slowly but still wants to finish eating all the bananas before the guards return.
-Return the minimum integer K
such that she can eat all the bananas within H
hours.
+Return the minimum integer k
such that she can eat all the bananas within h
hours.
Example 1:
-Input: piles = [3,6,7,11], H = 8
+
+
+Input: piles = [3,6,7,11], h = 8
Output: 4
-
Example 2:
-Input: piles = [30,11,23,4,20], H = 5
+
+
+Example 2:
+
+
+Input: piles = [30,11,23,4,20], h = 5
Output: 30
-
Example 3:
-Input: piles = [30,11,23,4,20], H = 6
+
+
+Example 3:
+
+
+Input: piles = [30,11,23,4,20], h = 6
Output: 23
+
Constraints:
- 1 <= piles.length <= 10^4
- piles.length <= H <= 10^9
- 1 <= piles[i] <= 10^9
+ 1 <= piles.length <= 104
+ piles.length <= h <= 109
+ 1 <= piles[i] <= 109
### Related Topics
diff --git a/problems/kth-largest-element-in-an-array/README.md b/problems/kth-largest-element-in-an-array/README.md
index e3227feed..1545efc36 100644
--- a/problems/kth-largest-element-in-an-array/README.md
+++ b/problems/kth-largest-element-in-an-array/README.md
@@ -11,23 +11,25 @@
## [215. Kth Largest Element in an Array (Medium)](https://leetcode.com/problems/kth-largest-element-in-an-array "数组中的第K个最大元素")
-Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.
+Given an integer array nums
and an integer k
, return the kth
largest element in the array.
-Example 1:
+Note that it is the kth
largest element in the sorted order, not the kth
distinct element.
-
-Input: [3,2,1,5,6,4]
and k = 2
+
+Example 1:
+Input: nums = [3,2,1,5,6,4], k = 2
Output: 5
+
Example 2:
+Input: nums = [3,2,3,1,2,4,5,5,6], k = 4
+Output: 4
+
+Constraints:
-Example 2:
-
-
-Input: [3,2,3,1,2,4,5,5,6]
and k = 4
-Output: 4
-
-Note:
-You may assume k is always valid, 1 ≤ k ≤ array's length.
+
+ 1 <= k <= nums.length <= 104
+ -104 <= nums[i] <= 104
+
### Related Topics
[[Heap](../../tag/heap/README.md)]
diff --git a/problems/largest-perimeter-triangle/README.md b/problems/largest-perimeter-triangle/README.md
index 843973455..41478ee1d 100644
--- a/problems/largest-perimeter-triangle/README.md
+++ b/problems/largest-perimeter-triangle/README.md
@@ -11,59 +11,29 @@
## [976. Largest Perimeter Triangle (Easy)](https://leetcode.com/problems/largest-perimeter-triangle "三角形的最大周长")
-Given an array A
of positive lengths, return the largest perimeter of a triangle with non-zero area, formed from 3 of these lengths.
-
-If it is impossible to form any triangle of non-zero area, return 0
.
+Given an integer array nums
, return the largest perimeter of a triangle with a non-zero area, formed from three of these lengths. If it is impossible to form any triangle of a non-zero area, return 0
.
-
-
-
-
-
Example 1:
-
-
-Input: [2,1,2]
-Output: 5
+Input: nums = [2,1,2]
+Output: 5
+
Example 2:
+Input: nums = [1,2,1]
+Output: 0
+
Example 3:
+Input: nums = [3,2,3,4]
+Output: 10
+
Example 4:
+Input: nums = [3,6,2,3]
+Output: 8
-
-
-
Example 2:
-
-
-Input: [1,2,1]
-Output: 0
-
-
-
-
Example 3:
-
-
-Input: [3,2,3,4]
-Output: 10
-
-
-
-
Example 4:
-
-
-Input: [3,6,2,3]
-Output: 8
-
-
+
Constraints:
-
Note:
-
-
- 3 <= A.length <= 10000
- 1 <= A[i] <= 10^6
-
-
-
-
-
+
+ 3 <= nums.length <= 104
+ 1 <= nums[i] <= 106
+
### Related Topics
[[Sort](../../tag/sort/README.md)]
diff --git a/problems/largest-rectangle-in-histogram/README.md b/problems/largest-rectangle-in-histogram/README.md
index b258adf12..a944c55db 100644
--- a/problems/largest-rectangle-in-histogram/README.md
+++ b/problems/largest-rectangle-in-histogram/README.md
@@ -11,26 +11,7 @@
## [84. Largest Rectangle in Histogram (Hard)](https://leetcode.com/problems/largest-rectangle-in-histogram "柱状图中最大的矩形")
-Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.
-
-
-
-
-Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3]
.
-
-
-
-
-The largest rectangle is shown in the shaded area, which has area = 10
unit.
-
-
-
-Example:
-
-
-Input: [2,1,5,6,2,3]
-Output: 10
-
+Given an array of integers heights
representing the histogram's bar height where the width of each bar is 1
, return the area of the largest rectangle in the histogram.
Example 1:
diff --git a/problems/last-stone-weight-ii/README.md b/problems/last-stone-weight-ii/README.md
index 0686f14ff..11c649299 100644
--- a/problems/last-stone-weight-ii/README.md
+++ b/problems/last-stone-weight-ii/README.md
@@ -11,39 +11,53 @@
## [1049. Last Stone Weight II (Medium)](https://leetcode.com/problems/last-stone-weight-ii "最后一块石头的重量 II")
-We have a collection of rocks, each rock has a positive integer weight.
+You are given an array of integers stones
where stones[i]
is the weight of the ith
stone.
-Each turn, we choose any two rocks and smash them together. Suppose the stones have weights x
and y
with x <= y
. The result of this smash is:
+We are playing a game with the stones. On each turn, we choose any two stones and smash them together. Suppose the stones have weights x
and y
with x <= y
. The result of this smash is:
- - If
x == y
, both stones are totally destroyed;
- - If
x != y
, the stone of weight x
is totally destroyed, and the stone of weight y
has new weight y-x
.
+ - If
x == y
, both stones are destroyed, and
+ - If
x != y
, the stone of weight x
is destroyed, and the stone of weight y
has new weight y - x
.
-At the end, there is at most 1 stone left. Return the smallest possible weight of this stone (the weight is 0 if there are no stones left.)
+At the end of the game, there is at most one stone left.
-
+Return the smallest possible weight of the left stone. If there are no stones left, return 0
.
+
Example 1:
-Input: [2,7,4,1,8,1]
-Output: 1
-Explanation:
-We can combine 2 and 4 to get 2 so the array converts to [2,7,1,8,1] then,
-we can combine 7 and 8 to get 1 so the array converts to [2,1,1,1] then,
-we can combine 2 and 1 to get 1 so the array converts to [1,1,1] then,
-we can combine 1 and 1 to get 0 so the array converts to [1] then that's the optimal value.
+Input: stones = [2,7,4,1,8,1]
+Output: 1
+Explanation:
+We can combine 2 and 4 to get 2, so the array converts to [2,7,1,8,1] then,
+we can combine 7 and 8 to get 1, so the array converts to [2,1,1,1] then,
+we can combine 2 and 1 to get 1, so the array converts to [1,1,1] then,
+we can combine 1 and 1 to get 0, so the array converts to [1], then that's the optimal value.
-
+Example 2:
-Note:
+
+Input: stones = [31,26,33,21,40]
+Output: 5
+
+
+Example 3:
-
+
+Input: stones = [1,2]
+Output: 1
+
+
+
+Constraints:
+
+
1 <= stones.length <= 30
1 <= stones[i] <= 100
-
+
### Related Topics
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
diff --git a/problems/longest-common-subsequence/README.md b/problems/longest-common-subsequence/README.md
index 75d8cfed4..a62f8c0bc 100644
--- a/problems/longest-common-subsequence/README.md
+++ b/problems/longest-common-subsequence/README.md
@@ -11,13 +11,15 @@
## [1143. Longest Common Subsequence (Medium)](https://leetcode.com/problems/longest-common-subsequence "最长公共子序列")
-Given two strings text1
and text2
, return the length of their longest common subsequence.
+Given two strings text1
and text2
, return the length of their longest common subsequence. If there is no common subsequence, return 0
.
-A subsequence of a string is a new string generated from the original string with some characters(can be none) deleted without changing the relative order of the remaining characters. (eg, "ace" is a subsequence of "abcde" while "aec" is not). A common subsequence of two strings is a subsequence that is common to both strings.
+A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.
-
+
+ - For example,
"ace"
is a subsequence of "abcde"
.
+
-If there is no common subsequence, return 0.
+A common subsequence of two strings is a subsequence that is common to both strings.
Example 1:
@@ -48,9 +50,8 @@
Constraints:
- 1 <= text1.length <= 1000
- 1 <= text2.length <= 1000
- - The input strings consist of lowercase English characters only.
+ 1 <= text1.length, text2.length <= 1000
+ text1
and text2
consist of only lowercase English characters.
### Related Topics
diff --git a/problems/longest-palindromic-subsequence/README.md b/problems/longest-palindromic-subsequence/README.md
index 267d342b3..a75e0a99b 100644
--- a/problems/longest-palindromic-subsequence/README.md
+++ b/problems/longest-palindromic-subsequence/README.md
@@ -11,35 +11,27 @@
## [516. Longest Palindromic Subsequence (Medium)](https://leetcode.com/problems/longest-palindromic-subsequence "最长回文子序列")
-Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.
+Given a string s
, find the longest palindromic subsequence's length in s
.
-Example 1:
-Input:
+A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.
-
-"bbbab"
-
-Output:
+
+Example 1:
-4
+Input: s = "bbbab"
+Output: 4
+Explanation: One possible longest palindromic subsequence is "bbbb".
-One possible longest palindromic subsequence is "bbbb".
-
-
-Example 2:
-Input:
+Example 2:
-"cbbd"
+Input: s = "cbbd"
+Output: 2
+Explanation: One possible longest palindromic subsequence is "bb".
-Output:
-
-2
-
-One possible longest palindromic subsequence is "bb".
Constraints:
diff --git a/problems/longest-substring-with-at-least-k-repeating-characters/README.md b/problems/longest-substring-with-at-least-k-repeating-characters/README.md
index 0889484c6..00017f565 100644
--- a/problems/longest-substring-with-at-least-k-repeating-characters/README.md
+++ b/problems/longest-substring-with-at-least-k-repeating-characters/README.md
@@ -9,7 +9,7 @@
[Next >](../rotate-function "Rotate Function")
-## [395. Longest Substring with At Least K Repeating Characters (Medium)](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters "至少有K个重复字符的最长子串")
+## [395. Longest Substring with At Least K Repeating Characters (Medium)](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters "至少有 K 个重复字符的最长子串")
Given a string s
and an integer k
, return the length of the longest substring of s
such that the frequency of each character in this substring is greater than or equal to k
.
diff --git a/problems/longest-word-in-dictionary-through-deleting/README.md b/problems/longest-word-in-dictionary-through-deleting/README.md
index c6d3d8a6b..d3283512a 100644
--- a/problems/longest-word-in-dictionary-through-deleting/README.md
+++ b/problems/longest-word-in-dictionary-through-deleting/README.md
@@ -11,41 +11,32 @@
## [524. Longest Word in Dictionary through Deleting (Medium)](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting "通过删除字母匹配到字典里最长单词")
-Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string.
+Given a string s
and a string array dictionary
, return the longest string in the dictionary that can be formed by deleting some of the given string characters. If there is more than one possible result, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string.
+
Example 1:
-Input:
-s = "abpcplea", d = ["ale","apple","monkey","plea"]
-
-Output:
-"apple"
+Input: s = "abpcplea", dictionary = ["ale","apple","monkey","plea"]
+Output: "apple"
-
-
Example 2:
-Input:
-s = "abpcplea", d = ["a","b","c"]
-
-Output:
-"a"
+Input: s = "abpcplea", dictionary = ["a","b","c"]
+Output: "a"
-
-Note:
-
-
- - All the strings in the input will only contain lower-case letters.
- - The size of the dictionary won't exceed 1,000.
- - The length of all the strings in the input won't exceed 1,000.
-
-
-
+Constraints:
+
+
+ 1 <= s.length <= 1000
+ 1 <= dictionary.length <= 1000
+ 1 <= dictionary[i].length <= 1000
+ s
and dictionary[i]
consist of lowercase English letters.
+
### Related Topics
[[Sort](../../tag/sort/README.md)]
diff --git a/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md
index a20ce965d..b272602b6 100644
--- a/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md
+++ b/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md
@@ -13,7 +13,7 @@
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.
-According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”
+According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p
and q
as the lowest node in T
that has both p
and q
as descendants (where we allow a node to be a descendant of itself).”
Example 1:
@@ -47,7 +47,7 @@
-109 <= Node.val <= 109
All Node.val
are unique.
p != q
- p
and q
will exist in the BST.
+ p
and q
will exist in the BST.
### Related Topics
diff --git a/problems/lowest-common-ancestor-of-a-binary-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-tree/README.md
index 868bb850d..477a0c0f9 100644
--- a/problems/lowest-common-ancestor-of-a-binary-tree/README.md
+++ b/problems/lowest-common-ancestor-of-a-binary-tree/README.md
@@ -13,7 +13,7 @@
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
-According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”
+According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p
and q
as the lowest node in T
that has both p
and q
as descendants (where we allow a node to be a descendant of itself).”
Example 1:
@@ -47,7 +47,7 @@
-109 <= Node.val <= 109
All Node.val
are unique.
p != q
- p
and q
will exist in the tree.
+ p
and q
will exist in the tree.
### Related Topics
diff --git a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md
new file mode 100644
index 000000000..7dbe899d4
--- /dev/null
+++ b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+[< Previous](../number-of-restricted-paths-from-first-to-last-node "Number of Restricted Paths From First to Last Node")
+
+[Next >](../maximize-the-beauty-of-the-garden "Maximize the Beauty of the Garden")
+
+## [1787. Make the XOR of All Segments Equal to Zero (Hard)](https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero "使所有区间的异或结果为零")
+
+You are given an array nums
and an integer k
. The XOR of a segment [left, right]
where left <= right
is the XOR
of all the elements with indices between left
and right
, inclusive: nums[left] XOR nums[left+1] XOR ... XOR nums[right]
.
+
+Return the minimum number of elements to change in the array such that the XOR
of all segments of size k
is equal to zero.
+
+
+Example 1:
+
+
+Input: nums = [1,2,0,3,0], k = 1
+Output: 3
+Explanation: Modify the array from [1,2,0,3,0] to from [0,0,0,0,0].
+
+
+Example 2:
+
+
+Input: nums = [3,4,5,2,1,7,3,4,7], k = 3
+Output: 3
+Explanation: Modify the array from [3,4,5,2,1,7,3,4,7] to [3,4,7,3,4,7,3,4,7].
+
+
+Example 3:
+
+
+Input: nums = [1,2,4,1,2,5,1,2,6], k = 3
+Output: 3
+Explanation: Modify the array from [1,2,4,1,2,5,1,2,6] to [1,2,3,1,2,3,1,2,3].
+
+
+Constraints:
+
+
+ 1 <= k <= nums.length <= 2000
+ 0 <= nums[i] < 210
+
+
+### Related Topics
+ [[Dynamic Programming](../../tag/dynamic-programming/README.md)]
+
+### Hints
+
+Hint 1
+Let's note that for the XOR of all segments with size K to be equal to zeros, nums[i] has to be equal to nums[i+k]
+
+
+
+Hint 2
+Basically, we need to make the first K elements have XOR = 0 and then modify them.
+
diff --git a/problems/max-points-on-a-line/README.md b/problems/max-points-on-a-line/README.md
index 316d5ef75..a9537e7fb 100644
--- a/problems/max-points-on-a-line/README.md
+++ b/problems/max-points-on-a-line/README.md
@@ -11,40 +11,32 @@
## [149. Max Points on a Line (Hard)](https://leetcode.com/problems/max-points-on-a-line "直线上最多的点数")
-Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
+Given an array of points
where points[i] = [xi, yi]
represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line.
+
Example 1:
-
+
-Input: [[1,1],[2,2],[3,3]]
+Input: points = [[1,1],[2,2],[3,3]]
Output: 3
-Explanation:
-^
-|
-| o
-| o
-| o
-+------------->
-0 1 2 3 4
Example 2:
-
+
-Input: [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
+Input: points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
Output: 4
-Explanation:
-^
-|
-| o
-| o o
-| o
-| o o
-+------------------->
-0 1 2 3 4 5 6
-NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.
+
+Constraints:
+
+
+ 1 <= points.length <= 300
+ points[i].length == 2
+ -104 <= xi, yi <= 104
+ - All the
points
are unique.
+
### Related Topics
[[Hash Table](../../tag/hash-table/README.md)]
diff --git a/problems/maximal-rectangle/README.md b/problems/maximal-rectangle/README.md
index dbcec2b6a..3d2c84181 100644
--- a/problems/maximal-rectangle/README.md
+++ b/problems/maximal-rectangle/README.md
@@ -55,7 +55,7 @@
rows == matrix.length
- cols == matrix.length
+ cols == matrix[i].length
0 <= row, cols <= 200
matrix[i][j]
is '0'
or '1'
.
diff --git a/problems/maximize-palindrome-length-from-subsequences/README.md b/problems/maximize-palindrome-length-from-subsequences/README.md
index 627b4c671..3652abf10 100644
--- a/problems/maximize-palindrome-length-from-subsequences/README.md
+++ b/problems/maximize-palindrome-length-from-subsequences/README.md
@@ -7,7 +7,7 @@
[< Previous](../maximum-score-from-performing-multiplication-operations "Maximum Score from Performing Multiplication Operations")
-Next >
+[Next >](../sort-features-by-popularity "Sort Features by Popularity")
## [1771. Maximize Palindrome Length From Subsequences (Hard)](https://leetcode.com/problems/maximize-palindrome-length-from-subsequences "由子序列构造的最长回文串的长度")
diff --git a/problems/maximize-the-beauty-of-the-garden/README.md b/problems/maximize-the-beauty-of-the-garden/README.md
new file mode 100644
index 000000000..45813fb91
--- /dev/null
+++ b/problems/maximize-the-beauty-of-the-garden/README.md
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+[< Previous](../make-the-xor-of-all-segments-equal-to-zero "Make the XOR of All Segments Equal to Zero")
+
+Next >
+
+## [1788. Maximize the Beauty of the Garden (Hard)](https://leetcode.com/problems/maximize-the-beauty-of-the-garden "")
+
+
+
+### Related Topics
+ [[Greedy](../../tag/greedy/README.md)]
+
+### Hints
+
+Hint 1
+Consider every possible beauty and its first and last index in flowers.
+
+
+
+Hint 2
+Remove all flowers with negative beauties within those indices.
+
diff --git a/problems/maximum-frequency-stack/README.md b/problems/maximum-frequency-stack/README.md
index 203c00854..37a7d0dda 100644
--- a/problems/maximum-frequency-stack/README.md
+++ b/problems/maximum-frequency-stack/README.md
@@ -11,60 +11,53 @@
## [895. Maximum Frequency Stack (Hard)](https://leetcode.com/problems/maximum-frequency-stack "最大频率栈")
-Implement FreqStack
, a class which simulates the operation of a stack-like data structure.
+Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack.
-FreqStack
has two functions:
+Implement the FreqStack
class:
- push(int x)
, which pushes an integer x
onto the stack.
- pop()
, which removes and returns the most frequent element in the stack.
+ FreqStack()
constructs an empty frequency stack.
+ void push(int val)
pushes an integer val
onto the top of the stack.
+ int pop()
removes and returns the most frequent element in the stack.
- - If there is a tie for most frequent element, the element closest to the top of the stack is removed and returned.
+ - If there is a tie for the most frequent element, the element closest to the stack's top is removed and returned.
-
Example 1:
-Input:
-["FreqStack","push","push","push","push","push","push","pop","pop","pop","pop"],
-[[],[5],[7],[5],[7],[4],[5],[],[],[],[]]
-Output: [null,null,null,null,null,null,null,5,7,5,4]
-Explanation:
-After making six .push operations, the stack is [5,7,5,7,4,5] from bottom to top. Then:
-
-pop() -> returns 5, as 5 is the most frequent.
-The stack becomes [5,7,5,7,4].
-
-pop() -> returns 7, as 5 and 7 is the most frequent, but 7 is closest to the top.
-The stack becomes [5,7,5,4].
-
-pop() -> returns 5.
-The stack becomes [5,7,4].
-
-pop() -> returns 4.
-The stack becomes [5,7].
+Input
+["FreqStack", "push", "push", "push", "push", "push", "push", "pop", "pop", "pop", "pop"]
+[[], [5], [7], [5], [7], [4], [5], [], [], [], []]
+Output
+[null, null, null, null, null, null, null, 5, 7, 5, 4]
+
+Explanation
+FreqStack freqStack = new FreqStack();
+freqStack.push(5); // The stack is [5]
+freqStack.push(7); // The stack is [5,7]
+freqStack.push(5); // The stack is [5,7,5]
+freqStack.push(7); // The stack is [5,7,5,7]
+freqStack.push(4); // The stack is [5,7,5,7,4]
+freqStack.push(5); // The stack is [5,7,5,7,4,5]
+freqStack.pop(); // return 5, as 5 is the most frequent. The stack becomes [5,7,5,7,4].
+freqStack.pop(); // return 7, as 5 and 7 is the most frequent, but 7 is closest to the top. The stack becomes [5,7,5,4].
+freqStack.pop(); // return 5, as 5 is the most frequent. The stack becomes [5,7,4].
+freqStack.pop(); // return 4, as 4, 5 and 7 is the most frequent, but 4 is closest to the top. The stack becomes [5,7].
-
-Note:
+Constraints:
- - Calls to
FreqStack.push(int x)
will be such that 0 <= x <= 10^9
.
- - It is guaranteed that
FreqStack.pop()
won't be called if the stack has zero elements.
- - The total number of
FreqStack.push
calls will not exceed 10000
in a single test case.
- - The total number of
FreqStack.pop
calls will not exceed 10000
in a single test case.
- - The total number of
FreqStack.push
and FreqStack.pop
calls will not exceed 150000
across all test cases.
+ 0 <= val <= 109
+ - At most
2 * 104
calls will be made to push
and pop
.
+ - It is guaranteed that there will be at least one element in the stack before calling
pop
.
-
-
### Related Topics
[[Stack](../../tag/stack/README.md)]
[[Hash Table](../../tag/hash-table/README.md)]
diff --git a/problems/maximum-gap/README.md b/problems/maximum-gap/README.md
index bc4492580..38be7a47a 100644
--- a/problems/maximum-gap/README.md
+++ b/problems/maximum-gap/README.md
@@ -11,31 +11,35 @@
## [164. Maximum Gap (Hard)](https://leetcode.com/problems/maximum-gap "最大间距")
-Given an unsorted array, find the maximum difference between the successive elements in its sorted form.
-
-Return 0 if the array contains less than 2 elements.
+Given an integer array nums
, return the maximum difference between two successive elements in its sorted form. If the array contains less than two elements, return 0
.
+
Example 1:
-Input: [3,6,9,1]
+Input: nums = [3,6,9,1]
Output: 3
-Explanation: The sorted form of the array is [1,3,6,9], either
- (3,6) or (6,9) has the maximum difference 3.
+Explanation: The sorted form of the array is [1,3,6,9], either (3,6) or (6,9) has the maximum difference 3.
+
Example 2:
-Input: [10]
+Input: nums = [10]
Output: 0
-Explanation: The array contains less than 2 elements, therefore return 0.
+Explanation: The array contains less than 2 elements, therefore return 0.
+
-Note:
+
+Constraints:
- - You may assume all elements in the array are non-negative integers and fit in the 32-bit signed integer range.
- - Try to solve it in linear time/space.
+ 1 <= nums.length <= 104
+ 0 <= nums[i] <= 109
+
+Follow up: Could you solve it in linear time/space?
+
### Related Topics
[[Sort](../../tag/sort/README.md)]
diff --git a/problems/maximum-product-subarray/README.md b/problems/maximum-product-subarray/README.md
index 9e981d397..3125d9fca 100644
--- a/problems/maximum-product-subarray/README.md
+++ b/problems/maximum-product-subarray/README.md
@@ -11,22 +11,36 @@
## [152. Maximum Product Subarray (Medium)](https://leetcode.com/problems/maximum-product-subarray "乘积最大子数组")
-Given an integer array nums
, find the contiguous subarray within an array (containing at least one number) which has the largest product.
+Given an integer array nums
, find a contiguous non-empty subarray within the array that has the largest product, and return the product.
+It is guaranteed that the answer will fit in a 32-bit integer.
+
+A subarray is a contiguous subsequence of the array.
+
+
Example 1:
-Input: [2,3,-2,4]
-Output: 6
-Explanation: [2,3] has the largest product 6.
+Input: nums = [2,3,-2,4]
+Output: 6
+Explanation: [2,3] has the largest product 6.
Example 2:
-Input: [-2,0,-1]
+Input: nums = [-2,0,-1]
Output: 0
-Explanation: The result cannot be 2, because [-2,-1] is not a subarray.
+Explanation: The result cannot be 2, because [-2,-1] is not a subarray.
+
+
+
+Constraints:
+
+
+ 1 <= nums.length <= 2 * 104
+ -10 <= nums[i] <= 10
+
### Related Topics
[[Array](../../tag/array/README.md)]
diff --git a/problems/maximum-subarray/README.md b/problems/maximum-subarray/README.md
index aa6c9f871..4685ab121 100644
--- a/problems/maximum-subarray/README.md
+++ b/problems/maximum-subarray/README.md
@@ -32,22 +32,8 @@
Example 3:
-Input: nums = [0]
-Output: 0
-
-
-Example 4:
-
-
-Input: nums = [-1]
-Output: -1
-
-
-Example 5:
-
-
-Input: nums = [-100000]
-Output: -100000
+Input: nums = [5,4,-1,7,8]
+Output: 23
diff --git a/problems/median-of-two-sorted-arrays/README.md b/problems/median-of-two-sorted-arrays/README.md
index fde07dd5e..9dcdd1d4b 100644
--- a/problems/median-of-two-sorted-arrays/README.md
+++ b/problems/median-of-two-sorted-arrays/README.md
@@ -13,8 +13,6 @@
Given two sorted arrays nums1
and nums2
of size m
and n
respectively, return the median of the two sorted arrays.
-Follow up: The overall run time complexity should be O(log (m+n))
.
-
Example 1:
@@ -65,6 +63,9 @@
-106 <= nums1[i], nums2[i] <= 106
+
+Follow up: The overall run time complexity should be O(log (m+n))
.
+
### Related Topics
[[Array](../../tag/array/README.md)]
[[Binary Search](../../tag/binary-search/README.md)]
diff --git a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md
new file mode 100644
index 000000000..2bf45ea82
--- /dev/null
+++ b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+[< Previous](../check-if-binary-string-has-at-most-one-segment-of-ones "Check if Binary String Has at Most One Segment of Ones")
+
+[Next >](../number-of-restricted-paths-from-first-to-last-node "Number of Restricted Paths From First to Last Node")
+
+## [1785. Minimum Elements to Add to Form a Given Sum (Medium)](https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum "构成特定和需要添加的最少元素")
+
+You are given an integer array nums
and two integers limit
and goal
. The array nums
has an interesting property that abs(nums[i]) <= limit
.
+
+Return the minimum number of elements you need to add to make the sum of the array equal to goal
. The array must maintain its property that abs(nums[i]) <= limit
.
+
+Note that abs(x)
equals x
if x >= 0
, and -x
otherwise.
+
+
+Example 1:
+
+
+Input: nums = [1,-1,1], limit = 3, goal = -4
+Output: 2
+Explanation: You can add -2 and -3, then the sum of the array will be 1 - 1 + 1 - 2 - 3 = -4.
+
+
+Example 2:
+
+
+Input: nums = [1,-10,9,1], limit = 100, goal = 0
+Output: 1
+
+
+
+Constraints:
+
+
+ 1 <= nums.length <= 105
+ 1 <= limit <= 106
+ -limit <= nums[i] <= limit
+ -109 <= goal <= 109
+
+
+### Related Topics
+ [[Greedy](../../tag/greedy/README.md)]
+
+### Hints
+
+Hint 1
+Try thinking about the problem as if the array is empty. Then you only need to form goal using elements whose absolute value is <= limit.
+
+
+
+Hint 2
+You can greedily set all of the elements except one to limit or -limit, so the number of elements you need is ceil(abs(goal)/ limit).
+
+
+
+Hint 3
+You can "normalize" goal by offsetting it by the sum of the array. For example, if the goal is 5 and the sum is -3, then it's exactly the same as if the goal is 8 and the array is empty.
+
+
+
+Hint 4
+The answer is ceil(abs(goal-sum)/limit) = (abs(goal-sum)+limit-1) / limit.
+
diff --git a/problems/minimum-moves-to-equal-array-elements/README.md b/problems/minimum-moves-to-equal-array-elements/README.md
index 5ec44f81f..cb3c5ecc6 100644
--- a/problems/minimum-moves-to-equal-array-elements/README.md
+++ b/problems/minimum-moves-to-equal-array-elements/README.md
@@ -11,22 +11,35 @@
## [453. Minimum Moves to Equal Array Elements (Easy)](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小操作次数使数组元素相等")
-Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.
+Given an integer array nums
of size n
, return the minimum number of moves required to make all array elements equal.
-Example:
-
-Input:
-[1,2,3]
+In one move, you can increment n - 1
elements of the array by 1
.
+
+
+Example 1:
-Output:
-3
+
+Input: nums = [1,2,3]
+Output: 3
+Explanation: Only three moves are needed (remember each move increments two elements):
+[1,2,3] => [2,3,3] => [3,4,3] => [4,4,4]
+
-Explanation:
-Only three moves are needed (remember each move increments two elements):
+Example 2:
-[1,2,3] => [2,3,3] => [3,4,3] => [4,4,4]
+
+Input: nums = [1,1,1]
+Output: 0
-
+
+
+Constraints:
+
+
+ n == nums.length
+ 1 <= nums.length <= 104
+ -109 <= nums[i] <= 109
+
### Related Topics
[[Math](../../tag/math/README.md)]
diff --git a/problems/minimum-score-triangulation-of-polygon/README.md b/problems/minimum-score-triangulation-of-polygon/README.md
index 4ac0645ed..b6e17a52d 100644
--- a/problems/minimum-score-triangulation-of-polygon/README.md
+++ b/problems/minimum-score-triangulation-of-polygon/README.md
@@ -11,57 +11,46 @@
## [1039. Minimum Score Triangulation of Polygon (Medium)](https://leetcode.com/problems/minimum-score-triangulation-of-polygon "多边形三角剖分的最低得分")
-Given N
, consider a convex N
-sided polygon with vertices labelled A[0], A[i], ..., A[N-1]
in clockwise order.
+You have a convex n
-sided polygon where each vertex has an integer value. You are given an integer array values
where values[i]
is the value of the ith
vertex (i.e., clockwise order).
-Suppose you triangulate the polygon into N-2
triangles. For each triangle, the value of that triangle is the product of the labels of the vertices, and the total score of the triangulation is the sum of these values over all N-2
triangles in the triangulation.
+You will triangulate the polygon into n - 2
triangles. For each triangle, the value of that triangle is the product of the values of its vertices, and the total score of the triangulation is the sum of these values over all n - 2
triangles in the triangulation.
-Return the smallest possible total score that you can achieve with some triangulation of the polygon.
+Return the smallest possible total score that you can achieve with some triangulation of the polygon.
-
-
-
-
-
Example 1:
-
+
-Input: [1,2,3]
-Output: 6
-Explanation: The polygon is already triangulated, and the score of the only triangle is 6.
+Input: values = [1,2,3]
+Output: 6
+Explanation: The polygon is already triangulated, and the score of the only triangle is 6.
-
Example 2:
-
-

-
+
-Input: [3,7,4,5]
-Output: 144
-Explanation: There are two triangulations, with possible scores: 3*7*5 + 4*5*7 = 245, or 3*4*5 + 3*4*7 = 144. The minimum score is 144.
+Input: values = [3,7,4,5]
+Output: 144
+Explanation: There are two triangulations, with possible scores: 3*7*5 + 4*5*7 = 245, or 3*4*5 + 3*4*7 = 144.
+The minimum score is 144.
-
Example 3:
-
+
-Input: [1,3,1,4,1,5]
-Output: 13
-Explanation: The minimum score triangulation has score 1*1*3 + 1*1*4 + 1*1*5 + 1*1*1 = 13.
+Input: values = [1,3,1,4,1,5]
+Output: 13
+Explanation: The minimum score triangulation has score 1*1*3 + 1*1*4 + 1*1*5 + 1*1*1 = 13.
+
Constraints:
-
Note:
-
-
- 3 <= A.length <= 50
- 1 <= A[i] <= 100
-
-
-
-
+
+ n == values.length
+ 3 <= n <= 50
+ 1 <= values[i] <= 100
+
### Related Topics
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
diff --git a/problems/most-common-word/README.md b/problems/most-common-word/README.md
index f36586ff2..3a96dcf61 100644
--- a/problems/most-common-word/README.md
+++ b/problems/most-common-word/README.md
@@ -11,18 +11,15 @@
## [819. Most Common Word (Easy)](https://leetcode.com/problems/most-common-word "最常见的单词")
-Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn't banned, and that the answer is unique.
+Given a string paragraph
and a string array of the banned words banned
, return the most frequent word that is not banned. It is guaranteed there is at least one word that is not banned, and that the answer is unique.
-Words in the list of banned words are given in lowercase, and free of punctuation. Words in the paragraph are not case sensitive. The answer is in lowercase.
+The words in paragraph
are case-insensitive and the answer should be returned in lowercase.
-
-Example:
+Example 1:
-Input:
-paragraph = "Bob hit a ball, the hit BALL flew far after it was hit."
-banned = ["hit"]
+Input: paragraph = "Bob hit a ball, the hit BALL flew far after it was hit.", banned = ["hit"]
Output: "ball"
Explanation:
"hit" occurs 3 times, but it is a banned word.
@@ -32,18 +29,22 @@ that punctuation is ignored (even if adjacent to words, such as "ball,"
and that "hit" isn't the answer even though it occurs more because it is banned.
-
+Example 2:
+
+
+Input: paragraph = "a.", banned = []
+Output: "a"
+
-Note:
+
+Constraints:
- 1 <= paragraph.length <= 1000
.
- 0 <= banned.length <= 100
.
- 1 <= banned[i].length <= 10
.
- - The answer is unique, and written in lowercase (even if its occurrences in
paragraph
may have uppercase symbols, and even if it is a proper noun.)
- paragraph
only consists of letters, spaces, or the punctuation symbols !?',;.
- - There are no hyphens or hyphenated words.
- - Words only consist of letters, never apostrophes or other punctuation symbols.
+ 1 <= paragraph.length <= 1000
+ - paragraph consists of English letters, space
' '
, or one of the symbols: "!?',;."
.
+ 0 <= banned.length <= 100
+ 1 <= banned[i].length <= 10
+ banned[i]
consists of only lowercase English letters.
### Related Topics
diff --git a/problems/move-zeroes/README.md b/problems/move-zeroes/README.md
index 855dd078e..78420e9e4 100644
--- a/problems/move-zeroes/README.md
+++ b/problems/move-zeroes/README.md
@@ -11,20 +11,28 @@
## [283. Move Zeroes (Easy)](https://leetcode.com/problems/move-zeroes "移动零")
-Given an array nums
, write a function to move all 0
's to the end of it while maintaining the relative order of the non-zero elements.
-
-Example:
-
-
-Input: [0,1,0,3,12]
-Output: [1,3,12,0,0]
-
-Note:
-
-
- - You must do this in-place without making a copy of the array.
- - Minimize the total number of operations.
-
+Given an integer array nums
, move all 0
's to the end of it while maintaining the relative order of the non-zero elements.
+
+Note that you must do this in-place without making a copy of the array.
+
+
+Example 1:
+Input: nums = [0,1,0,3,12]
+Output: [1,3,12,0,0]
+
Example 2:
+Input: nums = [0]
+Output: [0]
+
+
+Constraints:
+
+
+ 1 <= nums.length <= 104
+ -231 <= nums[i] <= 231 - 1
+
+
+
+Follow up: Could you minimize the total number of operations done?
### Related Topics
[[Array](../../tag/array/README.md)]
diff --git a/problems/n-ary-tree-postorder-traversal/README.md b/problems/n-ary-tree-postorder-traversal/README.md
index 9c86ee0ad..1877d7459 100644
--- a/problems/n-ary-tree-postorder-traversal/README.md
+++ b/problems/n-ary-tree-postorder-traversal/README.md
@@ -9,7 +9,7 @@
[Next >](../tag-validator "Tag Validator")
-## [590. N-ary Tree Postorder Traversal (Easy)](https://leetcode.com/problems/n-ary-tree-postorder-traversal "N叉树的后序遍历")
+## [590. N-ary Tree Postorder Traversal (Easy)](https://leetcode.com/problems/n-ary-tree-postorder-traversal "N 叉树的后序遍历")
Given an n-ary tree, return the postorder traversal of its nodes' values.
diff --git a/problems/n-ary-tree-preorder-traversal/README.md b/problems/n-ary-tree-preorder-traversal/README.md
index ec719eca8..8b1717293 100644
--- a/problems/n-ary-tree-preorder-traversal/README.md
+++ b/problems/n-ary-tree-preorder-traversal/README.md
@@ -9,7 +9,7 @@
[Next >](../n-ary-tree-postorder-traversal "N-ary Tree Postorder Traversal")
-## [589. N-ary Tree Preorder Traversal (Easy)](https://leetcode.com/problems/n-ary-tree-preorder-traversal "N叉树的前序遍历")
+## [589. N-ary Tree Preorder Traversal (Easy)](https://leetcode.com/problems/n-ary-tree-preorder-traversal "N 叉树的前序遍历")
Given an n-ary tree, return the preorder traversal of its nodes' values.
diff --git a/problems/number-of-1-bits/README.md b/problems/number-of-1-bits/README.md
index 5732c15d0..c5a399386 100644
--- a/problems/number-of-1-bits/README.md
+++ b/problems/number-of-1-bits/README.md
@@ -16,7 +16,7 @@
Note:
- - Note that in some languages such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
+ - Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
- In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 3, the input represents the signed integer.
-3
.
@@ -49,7 +49,7 @@
Constraints:
- - The input must be a binary string of length
32
+ - The input must be a binary string of length
32
.
diff --git a/problems/number-of-islands/README.md b/problems/number-of-islands/README.md
index f657b3ae2..e39630a2b 100644
--- a/problems/number-of-islands/README.md
+++ b/problems/number-of-islands/README.md
@@ -11,7 +11,7 @@
## [200. Number of Islands (Medium)](https://leetcode.com/problems/number-of-islands "岛屿数量")
-Given an m x n
2d grid
map of '1'
s (land) and '0'
s (water), return the number of islands.
+Given an m x n
2D binary grid grid
which represents a map of '1'
s (land) and '0'
s (water), return the number of islands.
An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
diff --git a/problems/number-of-matching-subsequences/README.md b/problems/number-of-matching-subsequences/README.md
index a73b2dbec..383d1cc65 100644
--- a/problems/number-of-matching-subsequences/README.md
+++ b/problems/number-of-matching-subsequences/README.md
@@ -11,24 +11,38 @@
## [792. Number of Matching Subsequences (Medium)](https://leetcode.com/problems/number-of-matching-subsequences "匹配子序列的单词数")
-Given string S
and a dictionary of words words
, find the number of words[i]
that is a subsequence of S
.
+Given a string s
and an array of strings words
, return the number of words[i]
that is a subsequence of s
.
+
+A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.
+
+
+ - For example,
"ace"
is a subsequence of "abcde"
.
+
+
+
+Example 1:
-Example :
-Input:
-S = "abcde"
-words = ["a", "bb", "acd", "ace"]
+Input: s = "abcde", words = ["a","bb","acd","ace"]
Output: 3
-Explanation: There are three words in words
that are a subsequence of S
: "a", "acd", "ace".
+Explanation: There are three strings in words that are a subsequence of s: "a", "acd", "ace".
+
+
+Example 2:
+
+
+Input: s = "dsahjpjauf", words = ["ahjpjau","ja","ahbwzgqnuk","tnmlanowax"]
+Output: 2
-Note:
+
+Constraints:
- - All words in
words
and S
will only consists of lowercase letters.
- - The length of
S
will be in the range of [1, 50000]
.
- - The length of
words
will be in the range of [1, 5000]
.
- - The length of
words[i]
will be in the range of [1, 50]
.
+ 1 <= s.length <= 5 * 104
+ 1 <= words.length <= 5000
+ 1 <= words[i].length <= 50
+ s
and words[i]
consist of only lowercase English letters.
### Related Topics
diff --git a/problems/number-of-restricted-paths-from-first-to-last-node/README.md b/problems/number-of-restricted-paths-from-first-to-last-node/README.md
new file mode 100644
index 000000000..17d6a7a58
--- /dev/null
+++ b/problems/number-of-restricted-paths-from-first-to-last-node/README.md
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+[< Previous](../minimum-elements-to-add-to-form-a-given-sum "Minimum Elements to Add to Form a Given Sum")
+
+[Next >](../make-the-xor-of-all-segments-equal-to-zero "Make the XOR of All Segments Equal to Zero")
+
+## [1786. Number of Restricted Paths From First to Last Node (Medium)](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数")
+
+There is an undirected weighted connected graph. You are given a positive integer n
which denotes that the graph has n
nodes labeled from 1
to n
, and an array edges
where each edges[i] = [ui, vi, weighti]
denotes that there is an edge between nodes ui
and vi
with weight equal to weighti
.
+
+A path from node start
to node end
is a sequence of nodes [z0, z1, z2, ..., zk]
such that z0 = start
and zk = end
and there is an edge between zi
and zi+1
where 0 <= i <= k-1
.
+
+The distance of a path is the sum of the weights on the edges of the path. Let distanceToLastNode(x)
denote the shortest distance of a path between node n
and node x
. A restricted path is a path that also satisfies that distanceToLastNode(zi) > distanceToLastNode(zi+1)
where 0 <= i <= k-1
.
+
+Return the number of restricted paths from node 1
to node n
. Since that number may be too large, return it modulo 109 + 7
.
+
+
+Example 1:
+
+
+Input: n = 5, edges = [[1,2,3],[1,3,3],[2,3,1],[1,4,2],[5,2,2],[3,5,1],[5,4,10]]
+Output: 3
+Explanation: Each circle contains the node number in black and its distanceToLastNode value in blue.
The three restricted paths are:
+1) 1 --> 2 --> 5
+2) 1 --> 2 --> 3 --> 5
+3) 1 --> 3 --> 5
+
+
+Example 2:
+
+
+Input: n = 7, edges = [[1,3,1],[4,1,2],[7,3,4],[2,5,3],[5,6,1],[6,7,2],[7,5,3],[2,6,4]]
+Output: 1
+Explanation: Each circle contains the node number in black and its distanceToLastNode value in blue.
The only restricted path is 1 --> 3 --> 7.
+
+
+
+Constraints:
+
+
+ 1 <= n <= 2 * 104
+ n - 1 <= edges.length <= 4 * 104
+ edges[i].length == 3
+ 1 <= ui, vi <= n
+ ui != vi
+ 1 <= weighti <= 105
+ - There is at most one edge between any two nodes.
+ - There is at least one path between any two nodes.
+
+
+### Related Topics
+ [[Graph](../../tag/graph/README.md)]
+ [[Dynamic Programming](../../tag/dynamic-programming/README.md)]
+
+### Hints
+
+Hint 1
+Run a Dijkstra from node numbered n to compute distance from the last node.
+
+
+
+Hint 2
+Consider all edges [u, v] one by one and direct them such that distance of u to n > distance of v to n. If both u and v are at the same distance from n, discard this edge.
+
+
+
+Hint 3
+Now this problem reduces to computing the number of paths from 1 to n in a DAG, a standard DP problem.
+
diff --git a/problems/number-of-ways-to-paint-n-3-grid/README.md b/problems/number-of-ways-to-paint-n-3-grid/README.md
index 52b5ea05a..0db030cab 100644
--- a/problems/number-of-ways-to-paint-n-3-grid/README.md
+++ b/problems/number-of-ways-to-paint-n-3-grid/README.md
@@ -11,20 +11,17 @@
## [1411. Number of Ways to Paint N × 3 Grid (Hard)](https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid "给 N x 3 网格图涂色的方案数")
-You have a grid
of size n x 3
and you want to paint each cell of the grid with exactly one of the three colours: Red, Yellow or Green while making sure that no two adjacent cells have the same colour (i.e no two cells that share vertical or horizontal sides have the same colour).
+You have a grid
of size n x 3
and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent cells have the same color (i.e., no two cells that share vertical or horizontal sides have the same color).
-You are given n
the number of rows of the grid.
-
-Return the number of ways you can paint this grid
. As the answer may grow large, the answer must be computed modulo 10^9 + 7
.
+Given n
the number of rows of the grid, return the number of ways you can paint this grid
. As the answer may grow large, the answer must be computed modulo 109 + 7
.
Example 1:
-
+
Input: n = 1
Output: 12
-Explanation: There are 12 possible way to paint the grid as shown:
-
+Explanation: There are 12 possible way to paint the grid as shown.
Example 2:
diff --git a/problems/odd-even-jump/README.md b/problems/odd-even-jump/README.md
index 847d6ac0d..85822e3bd 100644
--- a/problems/odd-even-jump/README.md
+++ b/problems/odd-even-jump/README.md
@@ -11,17 +11,17 @@
## [975. Odd Even Jump (Hard)](https://leetcode.com/problems/odd-even-jump "奇偶跳")
-You are given an integer array A
. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd-numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even-numbered jumps. Note that the jumps are numbered, not the indices.
+You are given an integer array arr
. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd-numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even-numbered jumps. Note that the jumps are numbered, not the indices.
You may jump forward from index i
to index j
(with i < j
) in the following way:
- - During odd-numbered jumps (i.e., jumps 1, 3, 5, ...), you jump to the index
j
such that A[i] <= A[j]
and A[j]
is the smallest possible value. If there are multiple such indices j
, you can only jump to the smallest such index j
.
- - During even-numbered jumps (i.e., jumps 2, 4, 6, ...), you jump to the index
j
such that A[i] >= A[j]
and A[j]
is the largest possible value. If there are multiple such indices j
, you can only jump to the smallest such index j
.
+ - During odd-numbered jumps (i.e., jumps 1, 3, 5, ...), you jump to the index
j
such that arr[i] <= arr[j]
and arr[j]
is the smallest possible value. If there are multiple such indices j
, you can only jump to the smallest such index j
.
+ - During even-numbered jumps (i.e., jumps 2, 4, 6, ...), you jump to the index
j
such that arr[i] >= arr[j]
and arr[j]
is the largest possible value. If there are multiple such indices j
, you can only jump to the smallest such index j
.
- It may be the case that for some index
i
, there are no legal jumps.
-A starting index is good if, starting from that index, you can reach the end of the array (index A.length - 1
) by jumping some number of times (possibly 0 or more than once).
+A starting index is good if, starting from that index, you can reach the end of the array (index arr.length - 1
) by jumping some number of times (possibly 0 or more than once).
Return the number of good starting indices.
@@ -29,11 +29,10 @@
Example 1:
-Input: A = [10,13,12,14,15]
+Input: arr = [10,13,12,14,15]
Output: 2
Explanation:
-From starting index i = 0, we can make our 1st jump to i = 2 (since A[2] is the smallest among A[1], A[2], A[3],
-A[4] that is greater or equal to A[0]), then we cannot jump any more.
+From starting index i = 0, we can make our 1st jump to i = 2 (since arr[2] is the smallest among arr[1], arr[2], arr[3], arr[4] that is greater or equal to arr[0]), then we cannot jump any more.
From starting index i = 1 and i = 2, we can make our 1st jump to i = 3, then we cannot jump any more.
From starting index i = 3, we can make our 1st jump to i = 4, so we have reached the end.
From starting index i = 4, we have reached the end already.
@@ -44,23 +43,14 @@ jumps.
Example 2:
-Input: A = [2,3,1,1,4]
+Input: arr = [2,3,1,1,4]
Output: 3
Explanation:
From starting index i = 0, we make jumps to i = 1, i = 2, i = 3:
-
-During our 1st jump (odd-numbered), we first jump to i = 1 because A[1] is the smallest value in [A[1], A[2],
-A[3], A[4]] that is greater than or equal to A[0].
-
-During our 2nd jump (even-numbered), we jump from i = 1 to i = 2 because A[2] is the largest value in [A[2], A[3],
-A[4]] that is less than or equal to A[1]. A[3] is also the largest value, but 2 is a smaller index, so we can
-only jump to i = 2 and not i = 3
-
-During our 3rd jump (odd-numbered), we jump from i = 2 to i = 3 because A[3] is the smallest value in [A[3], A[4]]
-that is greater than or equal to A[2].
-
+During our 1st jump (odd-numbered), we first jump to i = 1 because arr[1] is the smallest value in [arr[1], arr[2], arr[3], arr[4]] that is greater than or equal to arr[0].
+During our 2nd jump (even-numbered), we jump from i = 1 to i = 2 because arr[2] is the largest value in [arr[2], arr[3], arr[4]] that is less than or equal to arr[1]. arr[3] is also the largest value, but 2 is a smaller index, so we can only jump to i = 2 and not i = 3
+During our 3rd jump (odd-numbered), we jump from i = 2 to i = 3 because arr[3] is the smallest value in [arr[3], arr[4]] that is greater than or equal to arr[2].
We can't jump from i = 3 to i = 4, so the starting index i = 0 is not good.
-
In a similar manner, we can deduce that:
From starting index i = 1, we jump to i = 4, so we reach the end.
From starting index i = 2, we jump to i = 3, and then we can't jump anymore.
@@ -73,18 +63,17 @@ number of jumps.
Example 3:
-Input: A = [5,1,3,4,2]
+Input: arr = [5,1,3,4,2]
Output: 3
-Explanation:
-We can reach the end from starting indices 1, 2, and 4.
+Explanation: We can reach the end from starting indices 1, 2, and 4.
Constraints:
- 1 <= A.length <= 2 * 104
- 0 <= A[i] < 105
+ 1 <= arr.length <= 2 * 104
+ 0 <= arr[i] < 105
### Related Topics
diff --git a/problems/odd-even-linked-list/README.md b/problems/odd-even-linked-list/README.md
index 4abbe37ec..b936534d1 100644
--- a/problems/odd-even-linked-list/README.md
+++ b/problems/odd-even-linked-list/README.md
@@ -11,33 +11,38 @@
## [328. Odd Even Linked List (Medium)](https://leetcode.com/problems/odd-even-linked-list "奇偶链表")
-Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.
+Given the head
of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list.
-You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity.
+The first node is considered odd, and the second node is even, and so on.
-Example 1:
+Note that the relative order inside both the even and odd groups should remain as it was in the input.
+
+Example 1:
+
-Input: 1->2->3->4->5->NULL
-Output: 1->3->5->2->4->NULL
+Input: head = [1,2,3,4,5]
+Output: [1,3,5,2,4]
-Example 2:
-
+Example 2:
+
-Input: 2->1->3->5->6->4->7->NULL
-Output: 2->3->6->7->1->5->4->NULL
+Input: head = [2,1,3,5,6,4,7]
+Output: [2,3,6,7,1,5,4]
Constraints:
- - The relative order inside both the even and odd groups should remain as it was in the input.
- - The first node is considered odd, the second node even and so on ...
- - The length of the linked list is between
[0, 10^4]
.
+ - The number of nodes in the linked list is in the range
[0, 104]
.
+ -106 <= Node.val <= 106
+
+Follow up: Could you solve it in O(1)
space complexity and O(nodes)
time complexity?
+
### Related Topics
[[Linked List](../../tag/linked-list/README.md)]
diff --git a/problems/paint-fence/README.md b/problems/paint-fence/README.md
index 739c6dee1..3317001f8 100644
--- a/problems/paint-fence/README.md
+++ b/problems/paint-fence/README.md
@@ -9,7 +9,7 @@
[Next >](../find-the-celebrity "Find the Celebrity")
-## [276. Paint Fence (Easy)](https://leetcode.com/problems/paint-fence "栅栏涂色")
+## [276. Paint Fence (Medium)](https://leetcode.com/problems/paint-fence "栅栏涂色")
There is a fence with n posts, each post can be painted with one of the k colors.
diff --git a/problems/paint-house-ii/README.md b/problems/paint-house-ii/README.md
index 11ae17a5c..847316443 100644
--- a/problems/paint-house-ii/README.md
+++ b/problems/paint-house-ii/README.md
@@ -37,4 +37,4 @@ Could you solve it in O(nk) runtime?
1. [Product of Array Except Self](../product-of-array-except-self) (Medium)
1. [Sliding Window Maximum](../sliding-window-maximum) (Hard)
1. [Paint House](../paint-house) (Medium)
- 1. [Paint Fence](../paint-fence) (Easy)
+ 1. [Paint Fence](../paint-fence) (Medium)
diff --git a/problems/paint-house/README.md b/problems/paint-house/README.md
index 4ec08d22b..7867156c2 100644
--- a/problems/paint-house/README.md
+++ b/problems/paint-house/README.md
@@ -34,4 +34,4 @@ All costs are positive integers.
1. [House Robber](../house-robber) (Medium)
1. [House Robber II](../house-robber-ii) (Medium)
1. [Paint House II](../paint-house-ii) (Hard)
- 1. [Paint Fence](../paint-fence) (Easy)
+ 1. [Paint Fence](../paint-fence) (Medium)
diff --git a/problems/palindrome-linked-list/README.md b/problems/palindrome-linked-list/README.md
index 1bb515a82..f18a0ee0a 100644
--- a/problems/palindrome-linked-list/README.md
+++ b/problems/palindrome-linked-list/README.md
@@ -11,22 +11,33 @@
## [234. Palindrome Linked List (Easy)](https://leetcode.com/problems/palindrome-linked-list "回文链表")
-Given a singly linked list, determine if it is a palindrome.
+Given the head
of a singly linked list, return true
if it is a palindrome.
+
Example 1:
-
+
-Input: 1->2
-Output: false
+Input: head = [1,2,2,1]
+Output: true
+
Example 2:
-
+
-Input: 1->2->2->1
-Output: true
+Input: head = [1,2]
+Output: false
+
+
+
+Constraints:
+
+
+ - The number of nodes in the list is in the range
[1, 105]
.
+ 0 <= Node.val <= 9
+
-Follow up:
-Could you do it in O(n) time and O(1) space?
+
+Follow up: Could you do it in O(n)
time and O(1)
space?
### Related Topics
[[Linked List](../../tag/linked-list/README.md)]
diff --git a/problems/parallel-courses-ii/README.md b/problems/parallel-courses-ii/README.md
index 1bb3fea26..247da8ad5 100644
--- a/problems/parallel-courses-ii/README.md
+++ b/problems/parallel-courses-ii/README.md
@@ -11,11 +11,11 @@
## [1494. Parallel Courses II (Hard)](https://leetcode.com/problems/parallel-courses-ii "并行课程 II")
-Given the integer n
representing the number of courses at some university labeled from 1
to n
, and the array dependencies
where dependencies[i] = [xi, yi]
represents a prerequisite relationship, that is, the course xi
must be taken before the course yi
. Also, you are given the integer k
.
+Given the integer n
representing the number of courses at some university labeled from 1
to n
, and the array dependencies
where dependencies[i] = [xi, yi]
represents a prerequisite relationship, that is, the course xi
must be taken before the course yi
. Also, you are given the integer k
.
In one semester you can take at most k
courses as long as you have taken all the prerequisites for the courses you are taking.
-Return the minimum number of semesters to take all courses. It is guaranteed that you can take all courses in some way.
+Return the minimum number of semesters to take all courses. It is guaranteed that you can take all courses in some way.
Example 1:
@@ -51,9 +51,9 @@
1 <= n <= 15
1 <= k <= n
- 0 <= dependencies.length <= n * (n-1) / 2
+ 0 <= dependencies.length <= n * (n-1) / 2
dependencies[i].length == 2
- 1 <= xi, yi <= n
+ 1 <= xi, yi <= n
xi != yi
- All prerequisite relationships are distinct, that is,
dependencies[i] != dependencies[j]
.
- The given graph is a directed acyclic graph.
diff --git a/problems/parallel-courses/README.md b/problems/parallel-courses/README.md
index 823516bf4..b2eda5f2d 100644
--- a/problems/parallel-courses/README.md
+++ b/problems/parallel-courses/README.md
@@ -9,7 +9,7 @@
[Next >](../n-th-tribonacci-number "N-th Tribonacci Number")
-## [1136. Parallel Courses (Hard)](https://leetcode.com/problems/parallel-courses "平行课程")
+## [1136. Parallel Courses (Medium)](https://leetcode.com/problems/parallel-courses "平行课程")
There are N
courses, labelled from 1 to N
.
@@ -62,40 +62,15 @@ No course can be studied because they depend on each other.
### Hints
Hint 1
-Try to think of it as a graph problem.
+Try to think of it as a graph problem. It will be impossible to study all the courses if the graph had a cycle.
Hint 2
-When will be impossible to study all the courses?
+The graph is a directed acyclic graph (DAG). The answer is the longes path in this DAG.
Hint 3
-What if the directed graph has a cycle?
-
-
-
-Hint 4
-If you build a graph using the relations, what would be the graph type?
-
-
-
-Hint 5
-So the graph is a directed acyclic graph (DAG).
-
-
-
-Hint 6
-Imagine having a long path in the DAG, what can you say about the answer then?
-
-
-
-Hint 7
-How to find the longest path in a DAG?
-
-
-
-Hint 8
-We can use DP in order to solve this.
+You can use DP to find the longest path in the DAG.
diff --git a/problems/power-of-three/README.md b/problems/power-of-three/README.md
index c59c0a6f4..8be2c0ac1 100644
--- a/problems/power-of-three/README.md
+++ b/problems/power-of-three/README.md
@@ -37,7 +37,7 @@
-Follow up: Could you do it without using any loop / recursion?
+Follow up: Could you solve it without loops/recursion?
### Related Topics
[[Math](../../tag/math/README.md)]
diff --git a/problems/power-of-two/README.md b/problems/power-of-two/README.md
index e86dfa527..6ad9597ee 100644
--- a/problems/power-of-two/README.md
+++ b/problems/power-of-two/README.md
@@ -60,6 +60,9 @@
-231 <= n <= 231 - 1
+
+Follow up: Could you solve it without loops/recursion?
+
### Related Topics
[[Bit Manipulation](../../tag/bit-manipulation/README.md)]
[[Math](../../tag/math/README.md)]
diff --git a/problems/prison-cells-after-n-days/README.md b/problems/prison-cells-after-n-days/README.md
index e11dfd15f..ddcee25c5 100644
--- a/problems/prison-cells-after-n-days/README.md
+++ b/problems/prison-cells-after-n-days/README.md
@@ -11,36 +11,28 @@
## [957. Prison Cells After N Days (Medium)](https://leetcode.com/problems/prison-cells-after-n-days "N 天后的牢房")
-There are 8 prison cells in a row, and each cell is either occupied or vacant.
+There are 8
prison cells in a row and each cell is either occupied or vacant.
Each day, whether the cell is occupied or vacant changes according to the following rules:
- - If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied.
+ - If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied.
- Otherwise, it becomes vacant.
-(Note that because the prison is a row, the first and the last cells in the row can't have two adjacent neighbors.)
+Note that because the prison is a row, the first and the last cells in the row can't have two adjacent neighbors.
-We describe the current state of the prison in the following way: cells[i] == 1
if the i
-th cell is occupied, else cells[i] == 0
.
+You are given an integer array cells
where cells[i] == 1
if the ith
cell is occupied and cells[i] == 0
if the ith
cell is vacant, and you are given an integer n
.
-Given the initial state of the prison, return the state of the prison after N
days (and N
such changes described above.)
+Return the state of the prison after n
days (i.e., n
such changes described above).
-
-
-
-
Example 1:
-Input: cells = [0,1,0,1,1,0,0,1], N = 7
-Output: [0,0,1,1,0,0,0,0]
-Explanation:
-The following table summarizes the state of the prison on each day:
+Input: cells = [0,1,0,1,1,0,0,1], n = 7
+Output: [0,0,1,1,0,0,0,0]
+Explanation: The following table summarizes the state of the prison on each day:
Day 0: [0, 1, 0, 1, 1, 0, 0, 1]
Day 1: [0, 1, 1, 0, 0, 0, 0, 0]
Day 2: [0, 0, 0, 0, 1, 1, 1, 0]
@@ -48,29 +40,24 @@ Day 3: [0, 1, 1, 0, 0, 1, 0, 0]
Day 4: [0, 0, 0, 0, 0, 1, 0, 0]
Day 5: [0, 1, 1, 1, 0, 1, 0, 0]
Day 6: [0, 0, 1, 0, 1, 1, 0, 0]
-Day 7: [0, 0, 1, 1, 0, 0, 0, 0]
-
+Day 7: [0, 0, 1, 1, 0, 0, 0, 0]
-
Example 2:
-Input: cells = [1,0,0,1,0,0,1,0], N = 1000000000
-Output: [0,0,1,1,1,1,1,0]
+Input: cells = [1,0,0,1,0,0,1,0], n = 1000000000
+Output: [0,0,1,1,1,1,1,0]
+
Constraints:
-
Note:
-
-
+
cells.length == 8
- cells[i]
is in {0, 1}
- 1 <= N <= 10^9
-
-
-
+ cells[i]
is either 0
or 1
.
+ 1 <= n <= 109
+
### Related Topics
[[Hash Table](../../tag/hash-table/README.md)]
diff --git a/problems/products-price-for-each-store/README.md b/problems/products-price-for-each-store/README.md
new file mode 100644
index 000000000..2cf997444
--- /dev/null
+++ b/problems/products-price-for-each-store/README.md
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+[< Previous](../car-fleet-ii "Car Fleet II")
+
+[Next >](../shortest-path-in-a-hidden-grid "Shortest Path in a Hidden Grid")
+
+## [1777. Product's Price for Each Store (Easy)](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格")
+
+
diff --git a/problems/products-price-for-each-store/mysql_schemas.sql b/problems/products-price-for-each-store/mysql_schemas.sql
new file mode 100644
index 000000000..e1187f768
--- /dev/null
+++ b/problems/products-price-for-each-store/mysql_schemas.sql
@@ -0,0 +1,7 @@
+Create table If Not Exists Products (product_id int, store ENUM('store1', 'store2', 'store3'), price int);
+Truncate table Products;
+insert into Products (product_id, store, price) values ('0', 'store1', '95');
+insert into Products (product_id, store, price) values ('0', 'store3', '105');
+insert into Products (product_id, store, price) values ('0', 'store2', '100');
+insert into Products (product_id, store, price) values ('1', 'store1', '70');
+insert into Products (product_id, store, price) values ('1', 'store3', '80');
diff --git a/problems/recyclable-and-low-fat-products/README.md b/problems/recyclable-and-low-fat-products/README.md
index d591b2303..7a6203f4b 100644
--- a/problems/recyclable-and-low-fat-products/README.md
+++ b/problems/recyclable-and-low-fat-products/README.md
@@ -9,6 +9,6 @@
[Next >](../minimum-changes-to-make-alternating-binary-string "Minimum Changes To Make Alternating Binary String")
-## [1757. Recyclable and Low Fat Products (Easy)](https://leetcode.com/problems/recyclable-and-low-fat-products "")
+## [1757. Recyclable and Low Fat Products (Easy)](https://leetcode.com/problems/recyclable-and-low-fat-products "可回收且低脂的产品")
diff --git a/problems/remove-linked-list-elements/README.md b/problems/remove-linked-list-elements/README.md
index 085bfd5c4..4ef36a677 100644
--- a/problems/remove-linked-list-elements/README.md
+++ b/problems/remove-linked-list-elements/README.md
@@ -11,15 +11,39 @@
## [203. Remove Linked List Elements (Easy)](https://leetcode.com/problems/remove-linked-list-elements "移除链表元素")
-Remove all elements from a linked list of integers that have value val.
+Given the head
of a linked list and an integer val
, remove all the nodes of the linked list that has Node.val == val
, and return the new head.
-Example:
+
+Example 1:
+
+
+Input: head = [1,2,6,3,4,5,6], val = 6
+Output: [1,2,3,4,5]
+
+
+Example 2:
-Input: 1->2->6->3->4->5->6, val = 6
-Output: 1->2->3->4->5
+Input: head = [], val = 1
+Output: []
+Example 3:
+
+
+Input: head = [7,7,7,7], val = 7
+Output: []
+
+
+
+Constraints:
+
+
+ - The number of nodes in the list is in the range
[0, 104]
.
+ 1 <= Node.val <= 50
+ 0 <= k <= 50
+
+
### Related Topics
[[Linked List](../../tag/linked-list/README.md)]
diff --git a/problems/remove-palindromic-subsequences/README.md b/problems/remove-palindromic-subsequences/README.md
index 4380f54d4..3e2ee2ab9 100644
--- a/problems/remove-palindromic-subsequences/README.md
+++ b/problems/remove-palindromic-subsequences/README.md
@@ -11,7 +11,7 @@
## [1332. Remove Palindromic Subsequences (Easy)](https://leetcode.com/problems/remove-palindromic-subsequences "删除回文子序列")
-Given a string s
consisting only of letters 'a'
and 'b'
. In a single step you can remove one palindromic subsequence from s
.
+Given a string s
consisting only of letters 'a'
and 'b'
. In a single step you can remove one palindromic subsequence from s
.
Return the minimum number of steps to make the given string empty.
@@ -46,19 +46,12 @@ Remove palindromic subsequence "a" then "bb".
Remove palindromic subsequence "baab" then "b".
-Example 4:
-
-
-Input: s = ""
-Output: 0
-
-
Constraints:
- 0 <= s.length <= 1000
- s
only consists of letters 'a' and 'b'
+ 1 <= s.length <= 1000
+ s[i]
is either 'a'
or 'b'
.
### Related Topics
diff --git a/problems/reorder-list/README.md b/problems/reorder-list/README.md
index a556af73d..15cbbc4ec 100644
--- a/problems/reorder-list/README.md
+++ b/problems/reorder-list/README.md
@@ -11,21 +11,42 @@
## [143. Reorder List (Medium)](https://leetcode.com/problems/reorder-list "重排链表")
-Given a singly linked list L: L0→L1→…→Ln-1→Ln,
-reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
+You are given the head of a singly linked-list. The list can be represented as:
-You may not modify the values in the list's nodes, only nodes itself may be changed.
+
+L0 → L1 → … → Ln - 1 → Ln
+
-Example 1:
+Reorder the list to be on the following form:
-Given 1->2->3->4, reorder it to 1->4->2->3.
+L0 → Ln → L1 → Ln - 1 → L2 → Ln - 2 → …
+
-Example 2:
+You may not modify the values in the list's nodes. Only nodes themselves may be changed.
+
+
+Example 1:
+
+
+Input: head = [1,2,3,4]
+Output: [1,4,2,3]
+
+Example 2:
+
-Given 1->2->3->4->5, reorder it to 1->5->2->4->3.
+Input: head = [1,2,3,4,5]
+Output: [1,5,2,4,3]
+
+Constraints:
+
+
+ - The number of nodes in the list is in the range
[1, 5 * 104]
.
+ 1 <= Node.val <= 1000
+
+
### Related Topics
[[Linked List](../../tag/linked-list/README.md)]
diff --git a/problems/repeated-dna-sequences/README.md b/problems/repeated-dna-sequences/README.md
index 0740c11c5..2e352da8d 100644
--- a/problems/repeated-dna-sequences/README.md
+++ b/problems/repeated-dna-sequences/README.md
@@ -11,9 +11,15 @@
## [187. Repeated DNA Sequences (Medium)](https://leetcode.com/problems/repeated-dna-sequences "重复的DNA序列")
-All DNA is composed of a series of nucleotides abbreviated as 'A'
, 'C'
, 'G'
, and 'T'
, for example: "ACGAATTCCG"
. When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.
+The DNA sequence is composed of a series of nucleotides abbreviated as 'A'
, 'C'
, 'G'
, and 'T'
.
-Write a function to find all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule.
+
+ - For example,
"ACGAATTCCG"
is a DNA sequence.
+
+
+When studying DNA, it is useful to identify repeated sequences within the DNA.
+
+Given a string s
that represents a DNA sequence, return all the 10
-letter-long sequences (substrings) that occur more than once in a DNA molecule. You may return the answer in any order.
Example 1:
@@ -27,8 +33,8 @@
Constraints:
- 0 <= s.length <= 105
- s[i]
is 'A'
, 'C'
, 'G'
, or 'T'
.
+ 1 <= s.length <= 105
+ s[i]
is either 'A'
, 'C'
, 'G'
, or 'T'
.
### Related Topics
diff --git a/problems/reverse-string-ii/README.md b/problems/reverse-string-ii/README.md
index b968e041c..a7f75c867 100644
--- a/problems/reverse-string-ii/README.md
+++ b/problems/reverse-string-ii/README.md
@@ -11,22 +11,26 @@
## [541. Reverse String II (Easy)](https://leetcode.com/problems/reverse-string-ii "反转字符串 II")
-
-Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them. If there are less than 2k but greater than or equal to k characters, then reverse the first k characters and left the other as original.
-
-
-Example:
-
-Input: s = "abcdefg", k = 2
-Output: "bacdfeg"
+Given a string s
and an integer k
, reverse the first k
characters for every 2k
characters counting from the start of the string.
+
+If there are fewer than k
characters left, reverse all of them. If there are less than 2k
but greater than or equal to k
characters, then reverse the first k
characters and left the other as original.
+
+
+Example 1:
+Input: s = "abcdefg", k = 2
+Output: "bacdfeg"
+
Example 2:
+Input: s = "abcd", k = 2
+Output: "bacd"
-
+
+Constraints:
-Restrictions:
-
-- The string consists of lower English letters only.
-- Length of the given string and k will in the range [1, 10000]
-
+
+ 1 <= s.length <= 104
+ s
consists of only lowercase English letters.
+ 1 <= k <= 104
+
### Related Topics
[[String](../../tag/string/README.md)]
diff --git a/problems/reverse-words-in-a-string-iii/README.md b/problems/reverse-words-in-a-string-iii/README.md
index 8076b5b6d..033cce7e8 100644
--- a/problems/reverse-words-in-a-string-iii/README.md
+++ b/problems/reverse-words-in-a-string-iii/README.md
@@ -11,18 +11,26 @@
## [557. Reverse Words in a String III (Easy)](https://leetcode.com/problems/reverse-words-in-a-string-iii "反转字符串中的单词 III")
-Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
+Given a string s
, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
-Example 1:
-
-Input: "Let's take LeetCode contest"
-Output: "s'teL ekat edoCteeL tsetnoc"
+
+Example 1:
+Input: s = "Let's take LeetCode contest"
+Output: "s'teL ekat edoCteeL tsetnoc"
+
Example 2:
+Input: s = "God Ding"
+Output: "doG gniD"
-
+
+Constraints:
-Note:
-In the string, each word is separated by single space and there will not be any extra space in the string.
-
+
+ 1 <= s.length <= 5 * 104
+ s
contains printable ASCII characters.
+ s
does not contain any leading or trailing spaces.
+ - There is at least one word in
s
.
+ - All the words in
s
are separated by a single space.
+
### Related Topics
[[String](../../tag/string/README.md)]
diff --git a/problems/reverse-words-in-a-string/README.md b/problems/reverse-words-in-a-string/README.md
index b7ee01055..c83eac0e6 100644
--- a/problems/reverse-words-in-a-string/README.md
+++ b/problems/reverse-words-in-a-string/README.md
@@ -67,14 +67,7 @@
-
-Follow up:
-
-
- - Could you solve it in-place with
O(1)
extra space?
-
-
-
+Follow up: Could you solve it in-place with O(1)
extra space?
### Related Topics
[[String](../../tag/string/README.md)]
diff --git a/problems/russian-doll-envelopes/README.md b/problems/russian-doll-envelopes/README.md
index 69574adf1..f2d04ee88 100644
--- a/problems/russian-doll-envelopes/README.md
+++ b/problems/russian-doll-envelopes/README.md
@@ -11,22 +11,38 @@
## [354. Russian Doll Envelopes (Hard)](https://leetcode.com/problems/russian-doll-envelopes "俄罗斯套娃信封问题")
-You have a number of envelopes with widths and heights given as a pair of integers (w, h)
. One envelope can fit into another if and only if both the width and height of one envelope is greater than the width and height of the other envelope.
+You are given a 2D array of integers envelopes
where envelopes[i] = [wi, hi]
represents the width and the height of an envelope.
-What is the maximum number of envelopes can you Russian doll? (put one inside other)
+One envelope can fit into another if and only if both the width and height of one envelope is greater than the width and height of the other envelope.
-Note:
-Rotation is not allowed.
+Return the maximum number of envelopes can you Russian doll (i.e., put one inside the other).
-Example:
+Note: You cannot rotate an envelope.
+
+
+Example 1:
-
-Input: [[5,4],[6,4],[6,7],[2,3]]
-Output: 3
-Explanation: The maximum number of envelopes you can Russian doll is 3
([2,3] => [5,4] => [6,7]).
+Input: envelopes = [[5,4],[6,4],[6,7],[2,3]]
+Output: 3
+Explanation: The maximum number of envelopes you can Russian doll is 3
([2,3] => [5,4] => [6,7]).
-
+
+Example 2:
+
+
+Input: envelopes = [[1,1],[1,1],[1,1]]
+Output: 1
+
+
+
+Constraints:
+
+
+ 1 <= envelopes.length <= 5000
+ envelopes[i].length == 2
+ 1 <= wi, hi <= 104
+
### Related Topics
[[Binary Search](../../tag/binary-search/README.md)]
diff --git a/problems/search-a-2d-matrix-ii/README.md b/problems/search-a-2d-matrix-ii/README.md
index 0c9894026..270c208cc 100644
--- a/problems/search-a-2d-matrix-ii/README.md
+++ b/problems/search-a-2d-matrix-ii/README.md
@@ -11,7 +11,7 @@
## [240. Search a 2D Matrix II (Medium)](https://leetcode.com/problems/search-a-2d-matrix-ii "搜索二维矩阵 II")
-Write an efficient algorithm that searches for a target
value in an m x n
integer matrix
. The matrix
has the following properties:
+Write an efficient algorithm that searches for a target
value in an m x n
integer matrix
. The matrix
has the following properties:
- Integers in each row are sorted in ascending from left to right.
diff --git a/problems/short-encoding-of-words/README.md b/problems/short-encoding-of-words/README.md
index c45811240..319b94133 100644
--- a/problems/short-encoding-of-words/README.md
+++ b/problems/short-encoding-of-words/README.md
@@ -39,7 +39,6 @@ words[2] = "bell", the substring of s starting from indices[2] = 5 to
Input: words = ["t"]
Output: 2
Explanation: A valid encoding would be s = "t#" and indices = [0].
-
diff --git a/problems/shortest-path-in-a-hidden-grid/README.md b/problems/shortest-path-in-a-hidden-grid/README.md
new file mode 100644
index 000000000..791e8ad3f
--- /dev/null
+++ b/problems/shortest-path-in-a-hidden-grid/README.md
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+[< Previous](../products-price-for-each-store "Product's Price for Each Store")
+
+[Next >](../find-nearest-point-that-has-the-same-x-or-y-coordinate "Find Nearest Point That Has the Same X or Y Coordinate")
+
+## [1778. Shortest Path in a Hidden Grid (Medium)](https://leetcode.com/problems/shortest-path-in-a-hidden-grid "")
+
+
+
+### Related Topics
+ [[Depth-first Search](../../tag/depth-first-search/README.md)]
+ [[Breadth-first Search](../../tag/breadth-first-search/README.md)]
+ [[Graph](../../tag/graph/README.md)]
+
+### Hints
+
+Hint 1
+The grid is at a maximum 500 x 500, so it is clever to assume that the robot's initial cell is grid[501][501]
+
+
+
+Hint 2
+Run a DFS from the robot's position to make sure that you can reach the target, otherwise you should return -1.
+
+
+
+Hint 3
+Now that you are sure you can reach the target, run BFS to find the shortest path.
+
diff --git a/problems/sort-array-by-parity-ii/README.md b/problems/sort-array-by-parity-ii/README.md
index 6da52d820..b09b0298f 100644
--- a/problems/sort-array-by-parity-ii/README.md
+++ b/problems/sort-array-by-parity-ii/README.md
@@ -11,35 +11,37 @@
## [922. Sort Array By Parity II (Easy)](https://leetcode.com/problems/sort-array-by-parity-ii "按奇偶排序数组 II")
-Given an array A
of non-negative integers, half of the integers in A are odd, and half of the integers are even.
+Given an array of integers nums
, half of the integers in nums
are odd, and the other half are even.
-Sort the array so that whenever A[i]
is odd, i
is odd; and whenever A[i]
is even, i
is even.
+Sort the array so that whenever nums[i]
is odd, i
is odd, and whenever nums[i]
is even, i
is even.
-You may return any answer array that satisfies this condition.
+Return any answer array that satisfies this condition.
-
Example 1:
-Input: [4,2,5,7]
-Output: [4,5,2,7]
-Explanation: [4,7,2,5], [2,5,4,7], [2,7,4,5] would also have been accepted.
+Input: nums = [4,2,5,7]
+Output: [4,5,2,7]
+Explanation: [4,7,2,5], [2,5,4,7], [2,7,4,5] would also have been accepted.
-
-
-Note:
+Example 2:
-
- 2 <= A.length <= 20000
- A.length % 2 == 0
- 0 <= A[i] <= 1000
-
+
+Input: nums = [2,3]
+Output: [2,3]
+
-
+Constraints:
+
+
+ 2 <= nums.length <= 2 * 104
+ nums.length
is even.
+ - Half of the integers in
nums
are even.
+ 0 <= nums[i] <= 1000
+
### Related Topics
[[Sort](../../tag/sort/README.md)]
diff --git a/problems/sort-features-by-popularity/README.md b/problems/sort-features-by-popularity/README.md
new file mode 100644
index 000000000..e322bd8f1
--- /dev/null
+++ b/problems/sort-features-by-popularity/README.md
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+[< Previous](../maximize-palindrome-length-from-subsequences "Maximize Palindrome Length From Subsequences")
+
+[Next >](../count-items-matching-a-rule "Count Items Matching a Rule")
+
+## [1772. Sort Features by Popularity (Medium)](https://leetcode.com/problems/sort-features-by-popularity "按受欢迎程度排列功能")
+
+
+
+### Related Topics
+ [[Sort](../../tag/sort/README.md)]
+ [[Hash Table](../../tag/hash-table/README.md)]
+
+### Hints
+
+Hint 1
+Use a hash map to count the frequency of each word of each string.
+
+
+
+Hint 2
+Use the map for sorting the features.
+
diff --git a/problems/split-array-with-same-average/README.md b/problems/split-array-with-same-average/README.md
index 7a479df48..93d92b82d 100644
--- a/problems/split-array-with-same-average/README.md
+++ b/problems/split-array-with-same-average/README.md
@@ -11,26 +11,37 @@
## [805. Split Array With Same Average (Hard)](https://leetcode.com/problems/split-array-with-same-average "数组的均值分割")
-In a given integer array A, we must move every element of A to either list B or list C. (B and C initially start empty.)
+You are given an integer array nums
.
-Return true if and only if after such a move, it is possible that the average value of B is equal to the average value of C, and B and C are both non-empty.
+You should move each element of nums
into one of the two arrays A
and B
such that A
and B
are non-empty, and average(A) == average(B)
.
+
+Return true
if it is possible to achieve that and false
otherwise.
+
+Note that for an array arr
, average(arr)
is the sum of all the elements of arr
over the length of arr
.
+
+
+Example 1:
-Example :
-Input:
-[1,2,3,4,5,6,7,8]
+Input: nums = [1,2,3,4,5,6,7,8]
Output: true
-Explanation: We can split the array into [1,4,5,8] and [2,3,6,7], and both of them have the average of 4.5.
+Explanation: We can split the array into [1,4,5,8] and [2,3,6,7], and both of them have an average of 4.5.
-Note:
+Example 2:
-
- - The length of
A
will be in the range [1, 30].
- A[i]
will be in the range of [0, 10000]
.
-
+
+Input: nums = [3,1]
+Output: false
+
+Constraints:
+
+
+ 1 <= nums.length <= 30
+ 0 <= nums[i] <= 104
+
### Related Topics
[[Math](../../tag/math/README.md)]
diff --git a/problems/statistics-from-a-large-sample/README.md b/problems/statistics-from-a-large-sample/README.md
index b59d03b09..519bf51be 100644
--- a/problems/statistics-from-a-large-sample/README.md
+++ b/problems/statistics-from-a-large-sample/README.md
@@ -11,15 +11,17 @@
## [1093. Statistics from a Large Sample (Medium)](https://leetcode.com/problems/statistics-from-a-large-sample "大样本统计")
-We sampled integers between 0
and 255
, and stored the results in an array count
: count[k]
is the number of integers we sampled equal to k
.
+We sampled integers in the range [0, 255]
and stored the results in an array count where count[k]
is the number of integers we sampled equal to k
.
-Return the minimum, maximum, mean, median, and mode of the sample respectively, as an array of floating point numbers. The mode is guaranteed to be unique.
+Return the minimum, maximum, mean, median, and mode of the sample respectively, as an array of floating-point numbers. Answers within 10-5
of the actual answer will be considered accepted.
-(Recall that the median of a sample is:
+The mode is guaranteed to be unique.
+
+The median of a sample is:
- - The middle element, if the elements of the sample were sorted and the number of elements is odd;
- - The average of the middle two elements, if the elements of the sample were sorted and the number of elements is even.)
+ - The middle element, if the elements of the sample were sorted and the number of elements is odd, or
+ - The average of the middle two elements, if the elements of the sample were sorted and the number of elements is even.
@@ -33,12 +35,12 @@
Constraints:
-
+
count.length == 256
- 1 <= sum(count) <= 10^9
- - The mode of the sample that count represents is unique.
- - Answers within
10^-5
of the true value will be accepted as correct.
-
+ 0 <= count[i] <= 256
+ 1 <= sum(count) <= 109
+ The mode of the sample that count
represents is unique.
+
### Related Topics
[[Math](../../tag/math/README.md)]
diff --git a/problems/student-attendance-record-i/README.md b/problems/student-attendance-record-i/README.md
index 4cc3b0c62..db14aff35 100644
--- a/problems/student-attendance-record-i/README.md
+++ b/problems/student-attendance-record-i/README.md
@@ -11,34 +11,32 @@
## [551. Student Attendance Record I (Easy)](https://leetcode.com/problems/student-attendance-record-i "学生出勤记录 I")
-You are given a string representing an attendance record for a student. The record only contains the following three characters:
-
-
-
-- 'A' : Absent.
-- 'L' : Late.
-- 'P' : Present.
-
-
-
-
-A student could be rewarded if his attendance record doesn't contain more than one 'A' (absent) or more than two continuous 'L' (late).
-
-You need to return whether the student could be rewarded according to his attendance record.
-
-Example 1:
-
-Input: "PPALLP"
-Output: True
+You are given a string s
representing an attendance record for a student. The record only contains the following three characters:
+
+ 'A'
: Absent.
+ 'L'
: Late.
+ 'P'
: Present.
+
+
+A student could be rewarded if his attendance record does not contain more than one 'A'
(absent) or more than two consecutive 'L'
(late).
+
+Return true
if the student could be rewarded according to his attendance record, and false
otherwise.
+
+
+Example 1:
+Input: s = "PPALLP"
+Output: true
+
Example 2:
+Input: s = "PPALLL"
+Output: false
-
+
+Constraints:
-Example 2:
-
-Input: "PPALLL"
-Output: False
-
-
+
+ 1 <= s.length <= 1000
+ s[i]
is either 'A'
, 'L'
, or 'P'
.
+
### Related Topics
[[String](../../tag/string/README.md)]
diff --git a/problems/student-attendance-record-ii/README.md b/problems/student-attendance-record-ii/README.md
index 10ad57c82..20b3cfd87 100644
--- a/problems/student-attendance-record-ii/README.md
+++ b/problems/student-attendance-record-ii/README.md
@@ -11,35 +11,49 @@
## [552. Student Attendance Record II (Hard)](https://leetcode.com/problems/student-attendance-record-ii "学生出勤记录 II")
-Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after mod 109 + 7.
+Given an integer n
, return the number of all possible attendance records with length n
, which will be regarded as rewardable. The answer may be very large, return it modulo 109 + 7
.
A student attendance record is a string that only contains the following three characters:
-
-
-- 'A' : Absent.
-- 'L' : Late.
-- 'P' : Present.
-
-
+
+ 'A'
: Absent.
+ 'L'
: Late.
+ 'P'
: Present.
+
-
-A record is regarded as rewardable if it doesn't contain more than one 'A' (absent) or more than two continuous 'L' (late).
+A record is regarded as rewardable if it does not contain more than one 'A'
(absent) or more than two consecutive 'L'
(late).
+
+
+Example 1:
+
+
+Input: n = 2
+Output: 8
+Explanation: There are 8 records with length 2 will be regarded as rewardable:
+"PP" , "AP", "PA", "LP", "PL", "AL", "LA", "LL"
+Only "AA" won't be regarded as rewardable owing to more than one absent time.
+
+
+Example 2:
-Example 1:
-Input: n = 2
-Output: 8
-Explanation:
-There are 8 records with length 2 will be regarded as rewardable:
-"PP" , "AP", "PA", "LP", "PL", "AL", "LA", "LL"
-Only "AA" won't be regarded as rewardable owing to more than one absent times.
+Input: n = 1
+Output: 3
-
-Note:
-The value of n won't exceed 100,000.
-
+Example 3:
+
+
+Input: n = 10101
+Output: 183236316
+
+
+
+Constraints:
+
+
### Related Topics
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
diff --git a/problems/sum-of-beauty-of-all-substrings/README.md b/problems/sum-of-beauty-of-all-substrings/README.md
new file mode 100644
index 000000000..3f91dbd23
--- /dev/null
+++ b/problems/sum-of-beauty-of-all-substrings/README.md
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+[< Previous](../check-if-number-is-a-sum-of-powers-of-three "Check if Number is a Sum of Powers of Three")
+
+[Next >](../count-pairs-of-nodes "Count Pairs Of Nodes")
+
+## [1781. Sum of Beauty of All Substrings (Medium)](https://leetcode.com/problems/sum-of-beauty-of-all-substrings "所有子字符串美丽值之和")
+
+The beauty of a string is the difference in frequencies between the most frequent and least frequent characters.
+
+
+ - For example, the beauty of
"abaacc"
is 3 - 1 = 2
.
+
+
+Given a string s
, return the sum of beauty of all of its substrings.
+
+
+Example 1:
+
+
+Input: s = "aabcb"
+Output: 5
+Explanation: The substrings with non-zero beauty are ["aab","aabc","aabcb","abcb","bcb"], each with beauty equal to 1.
+
+Example 2:
+
+
+Input: s = "aabcbaa"
+Output: 17
+
+
+
+Constraints:
+
+
+ 1 <= s.length <= 500
+ s
consists of only lowercase English letters.
+
+
+### Related Topics
+ [[Hash Table](../../tag/hash-table/README.md)]
+ [[String](../../tag/string/README.md)]
+
+### Hints
+
+Hint 1
+Maintain a prefix sum for the frequencies of characters.
+
+
+
+Hint 2
+You can iterate over all substring then iterate over the alphabet and find which character appears most and which appears least using the prefix sum array
+
diff --git a/problems/sum-of-two-integers/README.md b/problems/sum-of-two-integers/README.md
index 2246f3da4..e28244e2c 100644
--- a/problems/sum-of-two-integers/README.md
+++ b/problems/sum-of-two-integers/README.md
@@ -9,27 +9,24 @@
[Next >](../super-pow "Super Pow")
-## [371. Sum of Two Integers (Easy)](https://leetcode.com/problems/sum-of-two-integers "两整数之和")
+## [371. Sum of Two Integers (Medium)](https://leetcode.com/problems/sum-of-two-integers "两整数之和")
-Calculate the sum of two integers a and b, but you are not allowed to use the operator +
and -
.
+Given two integers a
and b
, return the sum of the two integers without using the operators +
and -
.
-
+
Example 1:
-
-
-Input: a = 1, b = 2
-Output: 3
+Input: a = 1, b = 2
+Output: 3
+
Example 2:
+Input: a = 2, b = 3
+Output: 5
+
+Constraints:
-
-
Example 2:
-
-
-Input: a = -2, b = 3
-Output: 1
-
-
-
+
+ -1000 <= a, b <= 1000
+
### Related Topics
[[Bit Manipulation](../../tag/bit-manipulation/README.md)]
diff --git a/problems/sum-root-to-leaf-numbers/README.md b/problems/sum-root-to-leaf-numbers/README.md
index f5f8ef2f9..86cd2f79e 100644
--- a/problems/sum-root-to-leaf-numbers/README.md
+++ b/problems/sum-root-to-leaf-numbers/README.md
@@ -9,7 +9,7 @@
[Next >](../surrounded-regions "Surrounded Regions")
-## [129. Sum Root to Leaf Numbers (Medium)](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根到叶子节点数字之和")
+## [129. Sum Root to Leaf Numbers (Medium)](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根节点到叶节点数字之和")
You are given the root
of a binary tree containing digits from 0
to 9
only.
diff --git a/problems/super-egg-drop/README.md b/problems/super-egg-drop/README.md
index 469a1468f..940fd886a 100644
--- a/problems/super-egg-drop/README.md
+++ b/problems/super-egg-drop/README.md
@@ -11,63 +11,52 @@
## [887. Super Egg Drop (Hard)](https://leetcode.com/problems/super-egg-drop "鸡蛋掉落")
-You are given K
eggs, and you have access to a building with N
floors from 1
to N
.
+You are given k
eggs, and you have access to a building with n
floors labeled from 1
to n
.
-Each egg is identical in function, and if an egg breaks, you cannot drop it again.
+Each egg is identical in function, and if an egg breaks, you cannot drop it again.
-You know that there exists a floor F
with 0 <= F <= N
such that any egg dropped at a floor higher than F
will break, and any egg dropped at or below floor F
will not break.
+You know that there exists a floor f
with 0 <= f <= n
such that any egg dropped at a floor higher than f
will break, and any egg dropped at or below floor f
will not break.
-Each move, you may take an egg (if you have an unbroken one) and drop it from any floor X
(with 1 <= X <= N
).
+Each move, you may take an egg (if you have an unbroken one) and drop it from any floor x
(with 1 <= x <= n
).
-Your goal is to know with certainty what the value of F
is.
+Your goal is to know with certainty what the value of f
is.
-What is the minimum number of moves that you need to know with certainty what F
is, regardless of the initial value of F
?
+Return the minimum number of moves that you need to know with certainty the value of f
.
-
-
-
-
-
Example 1:
-Input: K = 1, N = 2
-Output: 2
+Input: k = 1, n = 2
+Output: 2
Explanation:
-Drop the egg from floor 1. If it breaks, we know with certainty that F = 0.
-Otherwise, drop the egg from floor 2. If it breaks, we know with certainty that F = 1.
-If it didn't break, then we know with certainty F = 2.
-Hence, we needed 2 moves in the worst case to know what F is with certainty.
+Drop the egg from floor 1. If it breaks, we know with certainty that f = 0.
+Otherwise, drop the egg from floor 2. If it breaks, we know with certainty that f = 1.
+If it did not break, then we know with certainty f = 2.
+Hence, we needed 2 moves in the worst case to know what f is with certainty.
-
Example 2:
-Input: K = 2, N = 6
-Output: 3
+Input: k = 2, n = 6
+Output: 3
-
Example 3:
-Input: K = 3, N = 14
-Output: 4
+Input: k = 3, n = 14
+Output: 4
+
Constraints:
-
Note:
-
-
- 1 <= K <= 100
- 1 <= N <= 10000
-
-
-
-
+
+ 1 <= k <= 100
+ 1 <= n <= 104
+
### Related Topics
[[Math](../../tag/math/README.md)]
diff --git a/problems/super-ugly-number/README.md b/problems/super-ugly-number/README.md
index df2add319..e12b2ba83 100644
--- a/problems/super-ugly-number/README.md
+++ b/problems/super-ugly-number/README.md
@@ -11,25 +11,38 @@
## [313. Super Ugly Number (Medium)](https://leetcode.com/problems/super-ugly-number "超级丑数")
-Write a program to find the nth
super ugly number.
+Given an integer n
and an array of integers primes
, return the nth
super ugly number.
-Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes
of size k
.
+Super ugly number is a positive number whose all prime factors are in the array primes
.
-Example:
+The nth
super ugly number is guaranteed to fit in a 32-bit signed integer.
+
+
+Example 1:
+
+
+Input: n = 12, primes = [2,7,13,19]
+Output: 32
+Explanation: [1,2,4,7,8,13,14,16,19,26,28,32] is the sequence of the first 12 super ugly numbers given primes == [2,7,13,19].
+
+
+Example 2:
-Input: n = 12, primes
= [2,7,13,19]
-Output: 32
-Explanation: [1,2,4,7,8,13,14,16,19,26,28,32]
is the sequence of the first 12
- super ugly numbers given primes
= [2,7,13,19]
of size 4.
+Input: n = 1, primes = [2,3,5]
+Output: 1
+Explanation: 1 is a super ugly number for any given primes.
+
-Note:
+
+Constraints:
- 1
is a super ugly number for any given primes
.
- - The given numbers in
primes
are in ascending order.
- - 0 <
k
≤ 100, 0 < n
≤ 106, 0 < primes[i]
< 1000.
- - The nth super ugly number is guaranteed to fit in a 32-bit signed integer.
+ 1 <= n <= 106
+ 1 <= primes.length <= 100
+ 2 <= primes[i] <= 1000
+ primes[i]
is guaranteed to be a prime number.
+ - All the values of
primes
are unique and sorted in ascending order.
### Related Topics
diff --git a/problems/transpose-file/README.md b/problems/transpose-file/README.md
index ec2f0ca36..7c56747f8 100644
--- a/problems/transpose-file/README.md
+++ b/problems/transpose-file/README.md
@@ -13,7 +13,7 @@
Given a text file file.txt
, transpose its content.
-You may assume that each row has the same number of columns and each field is separated by the ' '
character.
+You may assume that each row has the same number of columns, and each field is separated by the ' '
character.
Example:
@@ -31,5 +31,3 @@ ryan 30
name alice ryan
age 21 30
-
-
diff --git a/problems/ugly-number-ii/README.md b/problems/ugly-number-ii/README.md
index 12bc00022..3ae2905dd 100644
--- a/problems/ugly-number-ii/README.md
+++ b/problems/ugly-number-ii/README.md
@@ -11,23 +11,33 @@
## [264. Ugly Number II (Medium)](https://leetcode.com/problems/ugly-number-ii "丑数 II")
-Write a program to find the n
-th ugly number.
+Given an integer n
, return the nth
ugly number.
-Ugly numbers are positive numbers whose prime factors only include 2, 3, 5
.
+Ugly number is a positive number whose prime factors only include 2
, 3
, and/or 5
.
-Example:
+
+Example 1:
Input: n = 10
Output: 12
-Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12
is the sequence of the first 10
ugly numbers.
+Explanation: [1, 2, 3, 4, 5, 6, 8, 9, 10, 12] is the sequence of the first 10 ugly numbers.
+
-Note:
+Example 2:
-
- 1
is typically treated as an ugly number.
- n
does not exceed 1690.
-
+
+Input: n = 1
+Output: 1
+Explanation: 1 is typically treated as an ugly number.
+
+
+
+Constraints:
+
+
### Related Topics
[[Heap](../../tag/heap/README.md)]
diff --git a/problems/ugly-number-iii/README.md b/problems/ugly-number-iii/README.md
index 03f1f90e1..72cbe62de 100644
--- a/problems/ugly-number-iii/README.md
+++ b/problems/ugly-number-iii/README.md
@@ -21,14 +21,15 @@
Input: n = 3, a = 2, b = 3, c = 5
Output: 4
-Explanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is 4.
+Explanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is 4.
+
Example 2:
Input: n = 4, a = 2, b = 3, c = 4
Output: 6
-Explanation: The ugly numbers are 2, 3, 4, 6, 8, 9, 10, 12... The 4th is 6.
+Explanation: The ugly numbers are 2, 3, 4, 6, 8, 9, 10, 12... The 4th is 6.
Example 3:
@@ -36,7 +37,7 @@
Input: n = 5, a = 2, b = 11, c = 13
Output: 10
-Explanation: The ugly numbers are 2, 4, 6, 8, 10, 11, 12, 13... The 5th is 10.
+Explanation: The ugly numbers are 2, 4, 6, 8, 10, 11, 12, 13... The 5th is 10.
Example 4:
diff --git a/problems/ugly-number/README.md b/problems/ugly-number/README.md
index 47f61475e..42513d22b 100644
--- a/problems/ugly-number/README.md
+++ b/problems/ugly-number/README.md
@@ -11,39 +11,48 @@
## [263. Ugly Number (Easy)](https://leetcode.com/problems/ugly-number "丑数")
-Write a program to check whether a given number is an ugly number.
+Given an integer n
, return true
if n
is an ugly number.
-Ugly numbers are positive numbers whose prime factors only include 2, 3, 5
.
+Ugly number is a positive number whose prime factors only include 2
, 3
, and/or 5
.
+
Example 1:
-Input: 6
+Input: n = 6
Output: true
-Explanation: 6 = 2 × 3
+Explanation: 6 = 2 × 3
Example 2:
-Input: 8
+Input: n = 8
Output: true
-Explanation: 8 = 2 × 2 × 2
+Explanation: 8 = 2 × 2 × 2
Example 3:
-Input: 14
-Output: false
-Explanation: 14
is not ugly since it includes another prime factor 7
.
+Input: n = 14
+Output: false
+Explanation: 14 is not ugly since it includes another prime factor 7.
-Note:
+Example 4:
-
- 1
is typically treated as an ugly number.
- - Input is within the 32-bit signed integer range: [−231, 231 − 1].
-
+
+Input: n = 1
+Output: true
+Explanation: 1 is typically treated as an ugly number.
+
+
+
+Constraints:
+
+
### Related Topics
[[Math](../../tag/math/README.md)]
diff --git a/problems/unique-email-addresses/README.md b/problems/unique-email-addresses/README.md
index bd66b8fc8..736b95979 100644
--- a/problems/unique-email-addresses/README.md
+++ b/problems/unique-email-addresses/README.md
@@ -11,43 +11,55 @@
## [929. Unique Email Addresses (Easy)](https://leetcode.com/problems/unique-email-addresses "独特的电子邮件地址")
-Every email consists of a local name and a domain name, separated by the @ sign.
+Every valid email consists of a local name and a domain name, separated by the '@'
sign. Besides lowercase letters, the email may contain one or more '.'
or '+'
.
-For example, in alice@leetcode.com
, alice
is the local name, and leetcode.com
is the domain name.
+
+ - For example, in
"alice@leetcode.com"
, "alice"
is the local name, and "leetcode.com"
is the domain name.
+
-Besides lowercase letters, these emails may contain '.'
s or '+'
s.
+If you add periods '.'
between some characters in the local name part of an email address, mail sent there will be forwarded to the same address without dots in the local name. Note that this rule does not apply to domain names.
-If you add periods ('.'
) between some characters in the local name part of an email address, mail sent there will be forwarded to the same address without dots in the local name. For example, "alice.z@leetcode.com"
and "alicez@leetcode.com"
forward to the same email address. (Note that this rule does not apply for domain names.)
+
+ - For example,
"alice.z@leetcode.com"
and "alicez@leetcode.com"
forward to the same email address.
+
-If you add a plus ('+'
) in the local name, everything after the first plus sign will be ignored. This allows certain emails to be filtered, for example m.y+name@email.com
will be forwarded to my@email.com
. (Again, this rule does not apply for domain names.)
+If you add a plus '+'
in the local name, everything after the first plus sign will be ignored. This allows certain emails to be filtered. Note that this rule does not apply to domain names.
+
+
+ - For example,
"m.y+name@email.com"
will be forwarded to "my@email.com"
.
+
It is possible to use both of these rules at the same time.
-Given a list of emails
, we send one email to each address in the list. How many different addresses actually receive mails?
+Given an array of strings emails
where we send one email to each email[i]
, return the number of different addresses that actually receive mails.
-
-
Example 1:
-Input: ["test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","testemail+david@lee.tcode.com"]
-Output: 2
-Explanation: "testemail@leetcode.com" and "testemail@lee.tcode.com" actually receive mails
+Input: emails = ["test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","testemail+david@lee.tcode.com"]
+Output: 2
+Explanation: "testemail@leetcode.com" and "testemail@lee.tcode.com" actually receive mails.
-
+
Example 2:
+
+
+Input: emails = ["a@leetcode.com","b@leetcode.com","c@leetcode.com"]
+Output: 3
+
-
Note:
+
+
Constraints:
- 1 <= emails[i].length <= 100
1 <= emails.length <= 100
+ 1 <= emails[i].length <= 100
+ email[i]
consist of lowercase English letters, '+'
, '.'
and '@'
.
- Each
emails[i]
contains exactly one '@'
character.
- All local and domain names are non-empty.
- Local names do not start with a
'+'
character.
-
### Related Topics
[[String](../../tag/string/README.md)]
diff --git a/problems/valid-boomerang/README.md b/problems/valid-boomerang/README.md
index 4ae5826c4..a1275f407 100644
--- a/problems/valid-boomerang/README.md
+++ b/problems/valid-boomerang/README.md
@@ -11,40 +11,26 @@
## [1037. Valid Boomerang (Easy)](https://leetcode.com/problems/valid-boomerang "有效的回旋镖")
-A boomerang is a set of 3 points that are all distinct and not in a straight line.
+Given an array points
where points[i] = [xi, yi]
represents a point on the X-Y plane, return true
if these points are a boomerang.
-Given a list of three points in the plane, return whether these points are a boomerang.
+A boomerang is a set of three points that are all distinct and not in a straight line.
-
Example 1:
-
-
-Input: [[1,1],[2,3],[3,2]]
-Output: true
+Input: points = [[1,1],[2,3],[3,2]]
+Output: true
+
Example 2:
+Input: points = [[1,1],[2,2],[3,3]]
+Output: false
-
-
-
Example 2:
-
-
-Input: [[1,1],[2,2],[3,3]]
-Output: false
-
-
+Constraints:
-Note:
-
-
+
points.length == 3
points[i].length == 2
- 0 <= points[i][j] <= 100
-
-
-
+
0 <= xi, yi <= 100
+
### Related Topics
[[Math](../../tag/math/README.md)]
diff --git a/problems/valid-phone-numbers/README.md b/problems/valid-phone-numbers/README.md
index ff3a84800..bb41929e2 100644
--- a/problems/valid-phone-numbers/README.md
+++ b/problems/valid-phone-numbers/README.md
@@ -11,7 +11,7 @@
## [193. Valid Phone Numbers (Easy)](https://leetcode.com/problems/valid-phone-numbers "有效电话号码")
-Given a text file file.txt
that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers.
+Given a text file file.txt
that contains a list of phone numbers (one per line), write a one-liner bash script to print all valid phone numbers.
You may assume that a valid phone number must appear in one of the following two formats: (xxx) xxx-xxxx or xxx-xxx-xxxx. (x means a digit)
diff --git a/problems/word-break-ii/README.md b/problems/word-break-ii/README.md
index 5bfaa2a84..56c94652b 100644
--- a/problems/word-break-ii/README.md
+++ b/problems/word-break-ii/README.md
@@ -11,51 +11,43 @@
## [140. Word Break II (Hard)](https://leetcode.com/problems/word-break-ii "单词拆分 II")
-Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences.
+Given a string s
and a dictionary of strings wordDict
, add spaces in s
to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in any order.
-Note:
-
-
- - The same word in the dictionary may be reused multiple times in the segmentation.
- - You may assume the dictionary does not contain duplicate words.
-
+Note that the same word in the dictionary may be reused multiple times in the segmentation.
+
Example 1:
-Input:
-s = "catsanddog
"
-wordDict = ["cat", "cats", "and", "sand", "dog"]
-Output:
-[
- "cats and dog",
- "cat sand dog"
-]
+Input: s = "catsanddog", wordDict = ["cat","cats","and","sand","dog"]
+Output: ["cats and dog","cat sand dog"]
Example 2:
-Input:
-s = "pineapplepenapple"
-wordDict = ["apple", "pen", "applepen", "pine", "pineapple"]
-Output:
-[
- "pine apple pen apple",
- "pineapple pen apple",
- "pine applepen apple"
-]
+Input: s = "pineapplepenapple", wordDict = ["apple","pen","applepen","pine","pineapple"]
+Output: ["pine apple pen apple","pineapple pen apple","pine applepen apple"]
Explanation: Note that you are allowed to reuse a dictionary word.
Example 3:
-Input:
-s = "catsandog"
-wordDict = ["cats", "dog", "sand", "and", "cat"]
-Output:
-[]
+Input: s = "catsandog", wordDict = ["cats","dog","sand","and","cat"]
+Output: []
+
+
+
+Constraints:
+
+
+ 1 <= s.length <= 20
+ 1 <= wordDict.length <= 1000
+ 1 <= wordDict[i].length <= 10
+ s
and wordDict[i]
consist of only lowercase English letters.
+ - All the strings of
wordDict
are unique.
+
### Related Topics
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
diff --git a/problems/word-break/README.md b/problems/word-break/README.md
index b33b0291e..b061997e4 100644
--- a/problems/word-break/README.md
+++ b/problems/word-break/README.md
@@ -11,39 +11,46 @@
## [139. Word Break (Medium)](https://leetcode.com/problems/word-break "单词拆分")
-Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
+Given a string s
and a dictionary of strings wordDict
, return true
if s
can be segmented into a space-separated sequence of one or more dictionary words.
-Note:
-
-
- - The same word in the dictionary may be reused multiple times in the segmentation.
- - You may assume the dictionary does not contain duplicate words.
-
+Note that the same word in the dictionary may be reused multiple times in the segmentation.
+
Example 1:
-Input: s = "leetcode", wordDict = ["leet", "code"]
+Input: s = "leetcode", wordDict = ["leet","code"]
Output: true
-Explanation: Return true because "leetcode"
can be segmented as "leet code"
.
+Explanation: Return true because "leetcode" can be segmented as "leet code".
Example 2:
-Input: s = "applepenapple", wordDict = ["apple", "pen"]
+Input: s = "applepenapple", wordDict = ["apple","pen"]
Output: true
-Explanation: Return true because "
applepenapple"
can be segmented as "
apple pen apple"
.
- Note that you are allowed to reuse a dictionary word.
+Explanation: Return true because "applepenapple" can be segmented as "apple pen apple".
+Note that you are allowed to reuse a dictionary word.
Example 3:
-Input: s = "catsandog", wordDict = ["cats", "dog", "sand", "and", "cat"]
+Input: s = "catsandog", wordDict = ["cats","dog","sand","and","cat"]
Output: false
+
+Constraints:
+
+
+ 1 <= s.length <= 300
+ 1 <= wordDict.length <= 1000
+ 1 <= wordDict[i].length <= 20
+ s
and wordDict[i]
consist of only lowercase English letters.
+ - All the strings of
wordDict
are unique.
+
+
### Related Topics
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
diff --git a/problems/word-search/README.md b/problems/word-search/README.md
index b3ad25f25..7d0419bff 100644
--- a/problems/word-search/README.md
+++ b/problems/word-search/README.md
@@ -11,9 +11,11 @@
## [79. Word Search (Medium)](https://leetcode.com/problems/word-search "单词搜索")
-Given an m x n
board
and a word
, find if the word exists in the grid.
+Given an m x n
grid of characters board
and a string word
, return true
if word
exists in the grid.
-The word can be constructed from letters of sequentially adjacent cells, where "adjacent" cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.
+The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.
+
+Note: There will be some test cases with a board
or a word
larger than constraints to test if your solution is using pruning.
Example 1:
@@ -43,9 +45,9 @@
m == board.length
n = board[i].length
- 1 <= m, n <= 200
- 1 <= word.length <= 103
- board
and word
consists only of lowercase and uppercase English letters.
+ 1 <= m, n <= 6
+ 1 <= word.length <= 15
+ board
and word
consists of only lowercase and uppercase English letters.
### Related Topics
diff --git a/readme/1-300.md b/readme/1-300.md
index af0abba75..ee7426b72 100644
--- a/readme/1-300.md
+++ b/readme/1-300.md
@@ -114,7 +114,7 @@ LeetCode Problems' Solutions
| 42 | [Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water "接雨水") | [Go](../problems/trapping-rain-water) | Hard |
| 43 | [Multiply Strings](https://leetcode.com/problems/multiply-strings "字符串相乘") | [Go](../problems/multiply-strings) | Medium |
| 44 | [Wildcard Matching](https://leetcode.com/problems/wildcard-matching "通配符匹配") | [Go](../problems/wildcard-matching) | Hard |
-| 45 | [Jump Game II](https://leetcode.com/problems/jump-game-ii "跳跃游戏 II") | [Go](../problems/jump-game-ii) | Hard |
+| 45 | [Jump Game II](https://leetcode.com/problems/jump-game-ii "跳跃游戏 II") | [Go](../problems/jump-game-ii) | Medium |
| 46 | [Permutations](https://leetcode.com/problems/permutations "全排列") | [Go](../problems/permutations) | Medium |
| 47 | [Permutations II](https://leetcode.com/problems/permutations-ii "全排列 II") | [Go](../problems/permutations-ii) | Medium |
| 48 | [Rotate Image](https://leetcode.com/problems/rotate-image "旋转图像") | [Go](../problems/rotate-image) | Medium |
@@ -198,7 +198,7 @@ LeetCode Problems' Solutions
| 126 | [Word Ladder II](https://leetcode.com/problems/word-ladder-ii "单词接龙 II") | [Go](../problems/word-ladder-ii) | Hard |
| 127 | [Word Ladder](https://leetcode.com/problems/word-ladder "单词接龙") | [Go](../problems/word-ladder) | Hard |
| 128 | [Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence "最长连续序列") | [Go](../problems/longest-consecutive-sequence) | Hard |
-| 129 | [Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根到叶子节点数字之和") | [Go](../problems/sum-root-to-leaf-numbers) | Medium |
+| 129 | [Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根节点到叶节点数字之和") | [Go](../problems/sum-root-to-leaf-numbers) | Medium |
| 130 | [Surrounded Regions](https://leetcode.com/problems/surrounded-regions "被围绕的区域") | [Go](../problems/surrounded-regions) | Medium |
| 131 | [Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning "分割回文串") | [Go](../problems/palindrome-partitioning) | Medium |
| 132 | [Palindrome Partitioning II](https://leetcode.com/problems/palindrome-partitioning-ii "分割回文串 II") | [Go](../problems/palindrome-partitioning-ii) | Hard |
@@ -345,7 +345,7 @@ LeetCode Problems' Solutions
| 273 | [Integer to English Words](https://leetcode.com/problems/integer-to-english-words "整数转换英文表示") | [Go](../problems/integer-to-english-words) | Hard |
| 274 | [H-Index](https://leetcode.com/problems/h-index "H 指数") | [Go](../problems/h-index) | Medium |
| 275 | [H-Index II](https://leetcode.com/problems/h-index-ii "H 指数 II") | [Go](../problems/h-index-ii) | Medium |
-| 276 | [Paint Fence](https://leetcode.com/problems/paint-fence "栅栏涂色") 🔒 | [Go](../problems/paint-fence) | Easy |
+| 276 | [Paint Fence](https://leetcode.com/problems/paint-fence "栅栏涂色") 🔒 | [Go](../problems/paint-fence) | Medium |
| 277 | [Find the Celebrity](https://leetcode.com/problems/find-the-celebrity "搜寻名人") 🔒 | [Go](../problems/find-the-celebrity) | Medium |
| 278 | [First Bad Version](https://leetcode.com/problems/first-bad-version "第一个错误的版本") | [Go](../problems/first-bad-version) | Easy |
| 279 | [Perfect Squares](https://leetcode.com/problems/perfect-squares "完全平方数") | [Go](../problems/perfect-squares) | Medium |
@@ -354,7 +354,7 @@ LeetCode Problems' Solutions
| 282 | [Expression Add Operators](https://leetcode.com/problems/expression-add-operators "给表达式添加运算符") | [Go](../problems/expression-add-operators) | Hard |
| 283 | [Move Zeroes](https://leetcode.com/problems/move-zeroes "移动零") | [Go](../problems/move-zeroes) | Easy |
| 284 | [Peeking Iterator](https://leetcode.com/problems/peeking-iterator "顶端迭代器") | [Go](../problems/peeking-iterator) | Medium |
-| 285 | [Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的顺序后继") 🔒 | [Go](../problems/inorder-successor-in-bst) | Medium |
+| 285 | [Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的中序后继") 🔒 | [Go](../problems/inorder-successor-in-bst) | Medium |
| 286 | [Walls and Gates](https://leetcode.com/problems/walls-and-gates "墙与门") 🔒 | [Go](../problems/walls-and-gates) | Medium |
| 287 | [Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number "寻找重复数") | [Go](../problems/find-the-duplicate-number) | Medium |
| 288 | [Unique Word Abbreviation](https://leetcode.com/problems/unique-word-abbreviation "单词的唯一缩写") 🔒 | [Go](../problems/unique-word-abbreviation) | Medium |
diff --git a/readme/301-600.md b/readme/301-600.md
index abdde95ce..bacc496a6 100644
--- a/readme/301-600.md
+++ b/readme/301-600.md
@@ -164,7 +164,7 @@ LeetCode Problems' Solutions
| 392 | [Is Subsequence](https://leetcode.com/problems/is-subsequence "判断子序列") | [Go](../problems/is-subsequence) | Easy |
| 393 | [UTF-8 Validation](https://leetcode.com/problems/utf-8-validation "UTF-8 编码验证") | [Go](../problems/utf-8-validation) | Medium |
| 394 | [Decode String](https://leetcode.com/problems/decode-string "字符串解码") | [Go](../problems/decode-string) | Medium |
-| 395 | [Longest Substring with At Least K Repeating Characters](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters "至少有K个重复字符的最长子串") | [Go](../problems/longest-substring-with-at-least-k-repeating-characters) | Medium |
+| 395 | [Longest Substring with At Least K Repeating Characters](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters "至少有 K 个重复字符的最长子串") | [Go](../problems/longest-substring-with-at-least-k-repeating-characters) | Medium |
| 396 | [Rotate Function](https://leetcode.com/problems/rotate-function "旋转函数") | [Go](../problems/rotate-function) | Medium |
| 397 | [Integer Replacement](https://leetcode.com/problems/integer-replacement "整数替换") | [Go](../problems/integer-replacement) | Medium |
| 398 | [Random Pick Index](https://leetcode.com/problems/random-pick-index "随机数索引") | [Go](../problems/random-pick-index) | Medium |
@@ -226,7 +226,7 @@ LeetCode Problems' Solutions
| 454 | [4Sum II](https://leetcode.com/problems/4sum-ii "四数相加 II") | [Go](../problems/4sum-ii) | Medium |
| 455 | [Assign Cookies](https://leetcode.com/problems/assign-cookies "分发饼干") | [Go](../problems/assign-cookies) | Easy |
| 456 | [132 Pattern](https://leetcode.com/problems/132-pattern "132模式") | [Go](../problems/132-pattern) | Medium |
-| 457 | [Circular Array Loop](https://leetcode.com/problems/circular-array-loop "环形数组循环") | [Go](../problems/circular-array-loop) | Medium |
+| 457 | [Circular Array Loop](https://leetcode.com/problems/circular-array-loop "环形数组是否存在循环") | [Go](../problems/circular-array-loop) | Medium |
| 458 | [Poor Pigs](https://leetcode.com/problems/poor-pigs "可怜的小猪") | [Go](../problems/poor-pigs) | Hard |
| 459 | [Repeated Substring Pattern](https://leetcode.com/problems/repeated-substring-pattern "重复的子字符串") | [Go](../problems/repeated-substring-pattern) | Easy |
| 460 | [LFU Cache](https://leetcode.com/problems/lfu-cache "LFU 缓存") | [Go](../problems/lfu-cache) | Hard |
@@ -351,15 +351,15 @@ LeetCode Problems' Solutions
| 579 | [Find Cumulative Salary of an Employee](https://leetcode.com/problems/find-cumulative-salary-of-an-employee "查询员工的累计薪水") 🔒 | [MySQL](../problems/find-cumulative-salary-of-an-employee) | Hard |
| 580 | [Count Student Number in Departments](https://leetcode.com/problems/count-student-number-in-departments "统计各专业学生人数") 🔒 | [MySQL](../problems/count-student-number-in-departments) | Medium |
| 581 | [Shortest Unsorted Continuous Subarray](https://leetcode.com/problems/shortest-unsorted-continuous-subarray "最短无序连续子数组") | [Go](../problems/shortest-unsorted-continuous-subarray) | Medium |
-| 582 | [Kill Process](https://leetcode.com/problems/kill-process "杀死进程") 🔒 | [Go](../problems/kill-process) | Medium |
+| 582 | [Kill Process](https://leetcode.com/problems/kill-process "杀掉进程") 🔒 | [Go](../problems/kill-process) | Medium |
| 583 | [Delete Operation for Two Strings](https://leetcode.com/problems/delete-operation-for-two-strings "两个字符串的删除操作") | [Go](../problems/delete-operation-for-two-strings) | Medium |
| 584 | [Find Customer Referee](https://leetcode.com/problems/find-customer-referee "寻找用户推荐人") 🔒 | [MySQL](../problems/find-customer-referee) | Easy |
| 585 | [Investments in 2016](https://leetcode.com/problems/investments-in-2016 "2016年的投资") 🔒 | [MySQL](../problems/investments-in-2016) | Medium |
| 586 | [Customer Placing the Largest Number of Orders](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders "订单最多的客户") 🔒 | [MySQL](../problems/customer-placing-the-largest-number-of-orders) | Easy |
| 587 | [Erect the Fence](https://leetcode.com/problems/erect-the-fence "安装栅栏") | [Go](../problems/erect-the-fence) | Hard |
| 588 | [Design In-Memory File System](https://leetcode.com/problems/design-in-memory-file-system "设计内存文件系统") 🔒 | [Go](../problems/design-in-memory-file-system) | Hard |
-| 589 | [N-ary Tree Preorder Traversal](https://leetcode.com/problems/n-ary-tree-preorder-traversal "N叉树的前序遍历") | [Go](../problems/n-ary-tree-preorder-traversal) | Easy |
-| 590 | [N-ary Tree Postorder Traversal](https://leetcode.com/problems/n-ary-tree-postorder-traversal "N叉树的后序遍历") | [Go](../problems/n-ary-tree-postorder-traversal) | Easy |
+| 589 | [N-ary Tree Preorder Traversal](https://leetcode.com/problems/n-ary-tree-preorder-traversal "N 叉树的前序遍历") | [Go](../problems/n-ary-tree-preorder-traversal) | Easy |
+| 590 | [N-ary Tree Postorder Traversal](https://leetcode.com/problems/n-ary-tree-postorder-traversal "N 叉树的后序遍历") | [Go](../problems/n-ary-tree-postorder-traversal) | Easy |
| 591 | [Tag Validator](https://leetcode.com/problems/tag-validator "标签验证器") | [Go](../problems/tag-validator) | Hard |
| 592 | [Fraction Addition and Subtraction](https://leetcode.com/problems/fraction-addition-and-subtraction "分数加减运算") | [Go](../problems/fraction-addition-and-subtraction) | Medium |
| 593 | [Valid Square](https://leetcode.com/problems/valid-square "有效的正方形") | [Go](../problems/valid-square) | Medium |
diff --git a/readme/601-900.md b/readme/601-900.md
index 27be07057..a893646e9 100644
--- a/readme/601-900.md
+++ b/readme/601-900.md
@@ -193,7 +193,7 @@ LeetCode Problems' Solutions
| 721 | [Accounts Merge](https://leetcode.com/problems/accounts-merge "账户合并") | [Go](../problems/accounts-merge) | Medium |
| 722 | [Remove Comments](https://leetcode.com/problems/remove-comments "删除注释") | [Go](../problems/remove-comments) | Medium |
| 723 | [Candy Crush](https://leetcode.com/problems/candy-crush "粉碎糖果") 🔒 | [Go](../problems/candy-crush) | Medium |
-| 724 | [Find Pivot Index](https://leetcode.com/problems/find-pivot-index "寻找数组的中心索引") | [Go](../problems/find-pivot-index) | Easy |
+| 724 | [Find Pivot Index](https://leetcode.com/problems/find-pivot-index "寻找数组的中心下标") | [Go](../problems/find-pivot-index) | Easy |
| 725 | [Split Linked List in Parts](https://leetcode.com/problems/split-linked-list-in-parts "分隔链表") | [Go](../problems/split-linked-list-in-parts) | Medium |
| 726 | [Number of Atoms](https://leetcode.com/problems/number-of-atoms "原子的数量") | [Go](../problems/number-of-atoms) | Hard |
| 727 | [Minimum Window Subsequence](https://leetcode.com/problems/minimum-window-subsequence "最小窗口子序列") 🔒 | [Go](../problems/minimum-window-subsequence) | Hard |
diff --git a/readme/901-1200.md b/readme/901-1200.md
index c04d88e5d..cdd0dd513 100644
--- a/readme/901-1200.md
+++ b/readme/901-1200.md
@@ -305,7 +305,7 @@ LeetCode Problems' Solutions
| 1133 | [Largest Unique Number](https://leetcode.com/problems/largest-unique-number "最大唯一数") 🔒 | [Go](../problems/largest-unique-number) | Easy |
| 1134 | [Armstrong Number](https://leetcode.com/problems/armstrong-number "阿姆斯特朗数") 🔒 | [Go](../problems/armstrong-number) | Easy |
| 1135 | [Connecting Cities With Minimum Cost](https://leetcode.com/problems/connecting-cities-with-minimum-cost "最低成本联通所有城市") 🔒 | [Go](../problems/connecting-cities-with-minimum-cost) | Medium |
-| 1136 | [Parallel Courses](https://leetcode.com/problems/parallel-courses "平行课程") 🔒 | [Go](../problems/parallel-courses) | Hard |
+| 1136 | [Parallel Courses](https://leetcode.com/problems/parallel-courses "平行课程") 🔒 | [Go](../problems/parallel-courses) | Medium |
| 1137 | [N-th Tribonacci Number](https://leetcode.com/problems/n-th-tribonacci-number "第 N 个泰波那契数") | [Go](../problems/n-th-tribonacci-number) | Easy |
| 1138 | [Alphabet Board Path](https://leetcode.com/problems/alphabet-board-path "字母板上的路径") | [Go](../problems/alphabet-board-path) | Medium |
| 1139 | [Largest 1-Bordered Square](https://leetcode.com/problems/largest-1-bordered-square "最大的以 1 为边界的正方形") | [Go](../problems/largest-1-bordered-square) | Medium |
diff --git a/tag/README.md b/tag/README.md
index a81c4006c..d54aea1ae 100644
--- a/tag/README.md
+++ b/tag/README.md
@@ -12,14 +12,14 @@
| 1 | [Array](array/README.md) | [数组](https://openset.github.io/tags/array/) | | 2 | [Dynamic Programming](dynamic-programming/README.md) | [动态规划](https://openset.github.io/tags/dynamic-programming/) |
| 3 | [String](string/README.md) | [字符串](https://openset.github.io/tags/string/) | | 4 | [Math](math/README.md) | [数学](https://openset.github.io/tags/math/) |
| 5 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 6 | [Depth-first Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) |
-| 7 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 8 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) |
+| 7 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 8 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) |
| 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) |
| 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) |
| 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) |
| 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) |
| 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) |
-| 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) |
-| 21 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 22 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) |
+| 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) |
+| 21 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 22 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) |
| 23 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 24 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) |
| 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) |
| 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) |
diff --git a/tag/array/README.md b/tag/array/README.md
index f39e14f91..8dd280a2a 100644
--- a/tag/array/README.md
+++ b/tag/array/README.md
@@ -9,10 +9,12 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
+| 1779 | [找到最近的有相同 X 或 Y 坐标的点](../../problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | [[数组](../array/README.md)] | Easy |
+| 1773 | [统计匹配检索规则的物品数量](../../problems/count-items-matching-a-rule) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy |
| 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium |
| 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium |
| 1758 | [生成交替二进制字符串的最少操作数](../../problems/minimum-changes-to-make-alternating-binary-string) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy |
-| 1756 | [Design Most Recently Used Queue](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium |
+| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium |
| 1752 | [检查数组是否经排序和轮转得到](../../problems/check-if-array-is-sorted-and-rotated) | [[数组](../array/README.md)] | Easy |
| 1748 | [唯一元素的和](../../problems/sum-of-unique-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
| 1742 | [盒子中小球的最大数量](../../problems/maximum-number-of-balls-in-a-box) | [[数组](../array/README.md)] | Easy |
@@ -204,7 +206,7 @@
| 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] | Easy |
| 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy |
| 729 | [我的日程安排表 I](../../problems/my-calendar-i) | [[数组](../array/README.md)] | Medium |
-| 724 | [寻找数组的中心索引](../../problems/find-pivot-index) | [[数组](../array/README.md)] | Easy |
+| 724 | [寻找数组的中心下标](../../problems/find-pivot-index) | [[数组](../array/README.md)] | Easy |
| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium |
| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard |
| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
@@ -239,7 +241,7 @@
| 509 | [斐波那契数](../../problems/fibonacci-number) | [[数组](../array/README.md)] | Easy |
| 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] | Medium |
| 485 | [最大连续 1 的个数](../../problems/max-consecutive-ones) | [[数组](../array/README.md)] | Easy |
-| 457 | [环形数组循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium |
+| 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium |
| 448 | [找到所有数组中消失的数字](../../problems/find-all-numbers-disappeared-in-an-array) | [[数组](../array/README.md)] | Easy |
| 442 | [数组中重复的数据](../../problems/find-all-duplicates-in-an-array) | [[数组](../array/README.md)] | Medium |
| 414 | [第三大的数](../../problems/third-maximum-number) | [[数组](../array/README.md)] | Easy |
@@ -302,7 +304,7 @@
| 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] | Medium |
| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy |
| 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] | Medium |
-| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Hard |
+| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium |
| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
| 41 | [缺失的第一个正数](../../problems/first-missing-positive) | [[数组](../array/README.md)] | Hard |
| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md
index 124b4c278..94b8cca71 100644
--- a/tag/backtracking/README.md
+++ b/tag/backtracking/README.md
@@ -9,69 +9,3 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
-| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 1688 | [比赛中的配对次数](../../problems/count-of-matches-in-tournament) | [[回溯算法](../backtracking/README.md)] | Easy |
-| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[回溯算法](../backtracking/README.md)] | Hard |
-| 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[回溯算法](../backtracking/README.md)] | Medium |
-| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[回溯算法](../backtracking/README.md)] | Medium |
-| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 1291 | [顺次数](../../problems/sequential-digits) | [[回溯算法](../backtracking/README.md)] | Medium |
-| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 1258 | [近义词句子](../../problems/synonymous-sentences) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium |
-| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 1219 | [黄金矿工](../../problems/path-with-maximum-gold) | [[回溯算法](../backtracking/README.md)] | Medium |
-| 1215 | [步进数](../../problems/stepping-numbers) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium |
-| 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium |
-| 1079 | [活字印刷](../../problems/letter-tile-possibilities) | [[回溯算法](../backtracking/README.md)] | Medium |
-| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy |
-| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 306 | [累加数](../../problems/additive-number) | [[回溯算法](../backtracking/README.md)] | Medium |
-| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[极小化极大](../minimax/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium |
-| 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium |
-| 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium |
-| 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 93 | [复原 IP 地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 90 | [子集 II](../../problems/subsets-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 89 | [格雷编码](../../problems/gray-code) | [[回溯算法](../backtracking/README.md)] | Medium |
-| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 77 | [组合](../../problems/combinations) | [[回溯算法](../backtracking/README.md)] | Medium |
-| 60 | [排列序列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 52 | [N皇后 II](../../problems/n-queens-ii) | [[回溯算法](../backtracking/README.md)] | Hard |
-| 51 | [N 皇后](../../problems/n-queens) | [[回溯算法](../backtracking/README.md)] | Hard |
-| 47 | [全排列 II](../../problems/permutations-ii) | [[回溯算法](../backtracking/README.md)] | Medium |
-| 46 | [全排列](../../problems/permutations) | [[回溯算法](../backtracking/README.md)] | Medium |
-| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md
index 5e37da64c..51e2e5675 100644
--- a/tag/bit-manipulation/README.md
+++ b/tag/bit-manipulation/README.md
@@ -50,7 +50,7 @@
| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium |
| 393 | [UTF-8 编码验证](../../problems/utf-8-validation) | [[位运算](../bit-manipulation/README.md)] | Medium |
| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 371 | [两整数之和](../../problems/sum-of-two-integers) | [[位运算](../bit-manipulation/README.md)] | Easy |
+| 371 | [两整数之和](../../problems/sum-of-two-integers) | [[位运算](../bit-manipulation/README.md)] | Medium |
| 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] | Easy |
| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
diff --git a/tag/brainteaser/README.md b/tag/brainteaser/README.md
index 5c1d0aff4..64fa3edd0 100644
--- a/tag/brainteaser/README.md
+++ b/tag/brainteaser/README.md
@@ -9,10 +9,3 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
-| 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] | Medium |
-| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] | Easy |
-| 777 | [在LR字符串中交换相邻字符](../../problems/swap-adjacent-in-lr-string) | [[脑筋急转弯](../brainteaser/README.md)] | Medium |
-| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[脑筋急转弯](../brainteaser/README.md)] [[字符串](../string/README.md)] | Easy |
-| 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium |
-| 292 | [Nim 游戏](../../problems/nim-game) | [[脑筋急转弯](../brainteaser/README.md)] [[极小化极大](../minimax/README.md)] | Easy |
diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md
index f68972b31..e1ebf1d82 100644
--- a/tag/breadth-first-search/README.md
+++ b/tag/breadth-first-search/README.md
@@ -9,6 +9,7 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
+| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium |
| 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard |
| 1765 | [地图中的最高点](../../problems/map-of-highest-peak) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium |
| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md
index 92f2a97c3..3f0ef6a26 100644
--- a/tag/depth-first-search/README.md
+++ b/tag/depth-first-search/README.md
@@ -9,6 +9,7 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
+| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium |
| 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard |
| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
| 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium |
@@ -44,7 +45,7 @@
| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard |
| 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] | Hard |
| 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
+| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
| 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium |
@@ -129,7 +130,7 @@
| 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
| 364 | [加权嵌套序列和 II](../../problems/nested-list-weight-sum-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Medium |
| 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy |
-| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
+| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium |
| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard |
| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium |
@@ -145,7 +146,7 @@
| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium |
| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium |
-| 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
+| 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard |
| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
diff --git a/tag/design/README.md b/tag/design/README.md
index f50d33a44..14091cf0c 100644
--- a/tag/design/README.md
+++ b/tag/design/README.md
@@ -9,63 +9,3 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
-| 1756 | [Design Most Recently Used Queue](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium |
-| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium |
-| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy |
-| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium |
-| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard |
-| 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy |
-| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium |
-| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium |
-| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium |
-| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium |
-| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium |
-| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium |
-| 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium |
-| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium |
-| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium |
-| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] | Hard |
-| 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[设计](../design/README.md)] | Hard |
-| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 716 | [最大栈](../../problems/max-stack) 🔒 | [[设计](../design/README.md)] | Easy |
-| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium |
-| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy |
-| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard |
-| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium |
-| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium |
-| 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[设计](../design/README.md)] | Hard |
-| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium |
-| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] | Easy |
-| 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] | Hard |
-| 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard |
-| 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] | Hard |
-| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard |
-| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium |
-| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] | Medium |
-| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium |
-| 348 | [设计井字棋](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] | Medium |
-| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy |
-| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium |
-| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard |
-| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard |
-| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] | Medium |
-| 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] | Medium |
-| 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] | Medium |
-| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy |
-| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy |
-| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium |
-| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium |
-| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy |
-| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] | Medium |
diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md
index 22827330d..279bfab7a 100644
--- a/tag/divide-and-conquer/README.md
+++ b/tag/divide-and-conquer/README.md
@@ -17,7 +17,7 @@
| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard |
| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium |
-| 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
+| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard |
| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard |
| 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md
index 012e08c38..d831e0c26 100644
--- a/tag/dynamic-programming/README.md
+++ b/tag/dynamic-programming/README.md
@@ -9,6 +9,8 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
+| 1787 | [使所有区间的异或结果为零](../../problems/make-the-xor-of-all-segments-equal-to-zero) | [[动态规划](../dynamic-programming/README.md)] | Hard |
+| 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
| 1771 | [由子序列构造的最长回文串的长度](../../problems/maximize-palindrome-length-from-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard |
| 1770 | [执行乘法运算的最大分数](../../problems/maximum-score-from-performing-multiplication-operations) | [[动态规划](../dynamic-programming/README.md)] | Medium |
| 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
@@ -60,7 +62,7 @@
| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
| 1420 | [生成数组](../../problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | [[动态规划](../dynamic-programming/README.md)] | Hard |
| 1416 | [恢复数组](../../problems/restore-the-array) | [[动态规划](../dynamic-programming/README.md)] | Hard |
-| 1411 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-x-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard |
+| 1411 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard |
| 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard |
| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
| 1402 | [做菜顺序](../../problems/reducing-dishes) | [[动态规划](../dynamic-programming/README.md)] | Hard |
@@ -105,7 +107,7 @@
| 1143 | [最长公共子序列](../../problems/longest-common-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium |
| 1140 | [石子游戏 II](../../problems/stone-game-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium |
| 1139 | [最大的以 1 为边界的正方形](../../problems/largest-1-bordered-square) | [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
+| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
| 1105 | [填充书架](../../problems/filling-bookcase-shelves) | [[动态规划](../dynamic-programming/README.md)] | Medium |
@@ -214,6 +216,7 @@
| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
| 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
+| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
| 322 | [零钱兑换](../../problems/coin-change) | [[动态规划](../dynamic-programming/README.md)] | Medium |
| 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
| 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
@@ -222,7 +225,7 @@
| 303 | [区域和检索 - 数组不可变](../../problems/range-sum-query-immutable) | [[动态规划](../dynamic-programming/README.md)] | Easy |
| 300 | [最长递增子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 276 | [栅栏涂色](../../problems/paint-fence) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Easy |
+| 276 | [栅栏涂色](../../problems/paint-fence) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium |
| 265 | [粉刷房子 II](../../problems/paint-house-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard |
| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
| 256 | [粉刷房子](../../problems/paint-house) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium |
diff --git a/tag/geometry/README.md b/tag/geometry/README.md
index 085448301..5a8521ed2 100644
--- a/tag/geometry/README.md
+++ b/tag/geometry/README.md
@@ -9,12 +9,3 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
-| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard |
-| 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] | Hard |
-| 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] | Hard |
-| 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] | Medium |
-| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy |
-| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy |
-| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium |
-| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy |
-| 587 | [安装栅栏](../../problems/erect-the-fence) | [[几何](../geometry/README.md)] | Hard |
diff --git a/tag/graph/README.md b/tag/graph/README.md
index 3abb38b20..b0dee529a 100644
--- a/tag/graph/README.md
+++ b/tag/graph/README.md
@@ -9,6 +9,9 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
+| 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
+| 1782 | [统计点对的数目](../../problems/count-pairs-of-nodes) | [[图](../graph/README.md)] | Hard |
+| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium |
| 1765 | [地图中的最高点](../../problems/map-of-highest-peak) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium |
| 1761 | [一个图中连通三元组的最小度数](../../problems/minimum-degree-of-a-connected-trio-in-a-graph) | [[图](../graph/README.md)] | Hard |
| 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium |
@@ -30,7 +33,7 @@
| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard |
| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium |
| 1153 | [字符串转化](../../problems/string-transforms-into-another-string) 🔒 | [[图](../graph/README.md)] | Hard |
-| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
+| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium |
| 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium |
| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium |
diff --git a/tag/greedy/README.md b/tag/greedy/README.md
index 529ffe482..81f982b38 100644
--- a/tag/greedy/README.md
+++ b/tag/greedy/README.md
@@ -9,9 +9,14 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
+| 1788 | [Maximize the Beauty of the Garden](../../problems/maximize-the-beauty-of-the-garden) 🔒 | [[贪心算法](../greedy/README.md)] | Hard |
+| 1785 | [构成特定和需要添加的最少元素](../../problems/minimum-elements-to-add-to-form-a-given-sum) | [[贪心算法](../greedy/README.md)] | Medium |
+| 1784 | [检查二进制字符串字段](../../problems/check-if-binary-string-has-at-most-one-segment-of-ones) | [[贪心算法](../greedy/README.md)] | Easy |
+| 1775 | [通过最少操作次数使数组的和相等](../../problems/equal-sum-arrays-with-minimum-number-of-operations) | [[贪心算法](../greedy/README.md)] | Medium |
+| 1774 | [最接近目标价格的甜点成本](../../problems/closest-dessert-cost) | [[贪心算法](../greedy/README.md)] | Medium |
| 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium |
| 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium |
-| 1762 | [Buildings With an Ocean View](../../problems/buildings-with-an-ocean-view) 🔒 | [[贪心算法](../greedy/README.md)] | Medium |
+| 1762 | [能看到海景的建筑物](../../problems/buildings-with-an-ocean-view) 🔒 | [[贪心算法](../greedy/README.md)] | Medium |
| 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium |
| 1758 | [生成交替二进制字符串的最少操作数](../../problems/minimum-changes-to-make-alternating-binary-string) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy |
| 1754 | [构造字典序最大的合并字符串](../../problems/largest-merge-of-two-strings) | [[贪心算法](../greedy/README.md)] | Medium |
@@ -146,5 +151,5 @@
| 134 | [加油站](../../problems/gas-station) | [[贪心算法](../greedy/README.md)] | Medium |
| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy |
| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium |
-| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Hard |
+| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium |
| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md
index f78d7bc25..1adf15714 100644
--- a/tag/hash-table/README.md
+++ b/tag/hash-table/README.md
@@ -9,143 +9,3 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
-| 1748 | [唯一元素的和](../../problems/sum-of-unique-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 1726 | [同积元组](../../problems/tuple-with-same-product) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium |
-| 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[哈希表](../hash-table/README.md)] | Medium |
-| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium |
-| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium |
-| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium |
-| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium |
-| 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy |
-| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium |
-| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[哈希表](../hash-table/README.md)] | Medium |
-| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium |
-| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1224 | [最大相等频率](../../problems/maximum-equal-frequency) | [[哈希表](../hash-table/README.md)] | Hard |
-| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy |
-| 1207 | [独一无二的出现次数](../../problems/unique-number-of-occurrences) | [[哈希表](../hash-table/README.md)] | Easy |
-| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium |
-| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy |
-| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Hard |
-| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium |
-| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 1078 | [Bigram 分词](../../problems/occurrences-after-bigram) | [[哈希表](../hash-table/README.md)] | Easy |
-| 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[哈希表](../hash-table/README.md)] | Medium |
-| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard |
-| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 1001 | [网格照明](../../problems/grid-illumination) | [[哈希表](../hash-table/README.md)] | Hard |
-| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard |
-| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard |
-| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium |
-| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 970 | [强整数](../../problems/powerful-integers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium |
-| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium |
-| 961 | [重复 N 次的元素](../../problems/n-repeated-element-in-size-2n-array) | [[哈希表](../hash-table/README.md)] | Easy |
-| 957 | [N 天后的牢房](../../problems/prison-cells-after-n-days) | [[哈希表](../hash-table/README.md)] | Medium |
-| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 953 | [验证外星语词典](../../problems/verifying-an-alien-dictionary) | [[哈希表](../hash-table/README.md)] | Easy |
-| 939 | [最小面积矩形](../../problems/minimum-area-rectangle) | [[哈希表](../hash-table/README.md)] | Medium |
-| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium |
-| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Hard |
-| 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] | Easy |
-| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[哈希表](../hash-table/README.md)] | Easy |
-| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium |
-| 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] | Easy |
-| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard |
-| 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[哈希表](../hash-table/README.md)] | Easy |
-| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] | Easy |
-| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[哈希表](../hash-table/README.md)] | Easy |
-| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard |
-| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard |
-| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard |
-| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 645 | [错误的集合](../../problems/set-mismatch) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy |
-| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard |
-| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium |
-| 599 | [两个列表的最小索引总和](../../problems/minimum-index-sum-of-two-lists) | [[哈希表](../hash-table/README.md)] | Easy |
-| 594 | [最长和谐子序列](../../problems/longest-harmonious-subsequence) | [[哈希表](../hash-table/README.md)] | Easy |
-| 575 | [分糖果](../../problems/distribute-candies) | [[哈希表](../hash-table/README.md)] | Easy |
-| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 554 | [砖墙](../../problems/brick-wall) | [[哈希表](../hash-table/README.md)] | Medium |
-| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium |
-| 525 | [连续数组](../../problems/contiguous-array) | [[哈希表](../hash-table/README.md)] | Medium |
-| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 500 | [键盘行](../../problems/keyboard-row) | [[哈希表](../hash-table/README.md)] | Easy |
-| 463 | [岛屿的周长](../../problems/island-perimeter) | [[哈希表](../hash-table/README.md)] | Easy |
-| 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium |
-| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium |
-| 438 | [找到字符串中所有字母异位词](../../problems/find-all-anagrams-in-a-string) | [[哈希表](../hash-table/README.md)] | Medium |
-| 409 | [最长回文串](../../problems/longest-palindrome) | [[哈希表](../hash-table/README.md)] | Easy |
-| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy |
-| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard |
-| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard |
-| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium |
-| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy |
-| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy |
-| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
-| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard |
-| 325 | [和等于 k 的最长子数组长度](../../problems/maximum-size-subarray-sum-equals-k) 🔒 | [[哈希表](../hash-table/README.md)] | Medium |
-| 311 | [稀疏矩阵的乘法](../../problems/sparse-matrix-multiplication) 🔒 | [[哈希表](../hash-table/README.md)] | Medium |
-| 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] | Medium |
-| 290 | [单词规律](../../problems/word-pattern) | [[哈希表](../hash-table/README.md)] | Easy |
-| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[哈希表](../hash-table/README.md)] | Easy |
-| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium |
-| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy |
-| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 205 | [同构字符串](../../problems/isomorphic-strings) | [[哈希表](../hash-table/README.md)] | Easy |
-| 204 | [计数质数](../../problems/count-primes) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy |
-| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy |
-| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium |
-| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
-| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard |
-| 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium |
-| 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
-| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
-| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard |
-| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium |
-| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 36 | [有效的数独](../../problems/valid-sudoku) | [[哈希表](../hash-table/README.md)] | Medium |
-| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard |
-| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium |
-| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
-| 1 | [两数之和](../../problems/two-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy |
diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md
index 932db1472..592ea3e0f 100644
--- a/tag/line-sweep/README.md
+++ b/tag/line-sweep/README.md
@@ -9,9 +9,3 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
-| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium |
-| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium |
-| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium |
-| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard |
-| 391 | [完美矩形](../../problems/perfect-rectangle) | [[Line Sweep](../line-sweep/README.md)] | Hard |
-| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard |
diff --git a/tag/math/README.md b/tag/math/README.md
index 556dd37eb..7b2bfa353 100644
--- a/tag/math/README.md
+++ b/tag/math/README.md
@@ -9,6 +9,8 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
+| 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
+| 1776 | [车队 II](../../problems/car-fleet-ii) | [[数学](../math/README.md)] | Hard |
| 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard |
| 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium |
| 1744 | [你能在你最喜欢的那天吃到你最喜欢的糖果吗?](../../problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | [[数学](../math/README.md)] | Medium |
diff --git a/tag/queue/README.md b/tag/queue/README.md
index 88fe0bfa0..0c9155aea 100644
--- a/tag/queue/README.md
+++ b/tag/queue/README.md
@@ -15,7 +15,7 @@
| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium |
| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium |
| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium |
-| 582 | [杀死进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium |
+| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium |
| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium |
| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy |
diff --git a/tag/recursion/README.md b/tag/recursion/README.md
index ad51289a2..42f90d3a9 100644
--- a/tag/recursion/README.md
+++ b/tag/recursion/README.md
@@ -9,40 +9,3 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
-| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard |
-| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy |
-| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy |
-| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy |
-| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium |
-| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy |
-| 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[递归](../recursion/README.md)] | Medium |
-| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard |
-| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard |
-| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium |
-| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy |
-| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium |
-| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
-| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium |
-| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard |
-| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium |
-| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium |
-| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard |
-| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy |
-| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy |
-| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium |
-| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy |
-| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium |
-| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium |
diff --git a/tag/rejection-sampling/README.md b/tag/rejection-sampling/README.md
index fc2d396f2..8622c93e1 100644
--- a/tag/rejection-sampling/README.md
+++ b/tag/rejection-sampling/README.md
@@ -9,5 +9,3 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
-| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium |
-| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium |
diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md
index 56d607bc2..ee49220e1 100644
--- a/tag/sliding-window/README.md
+++ b/tag/sliding-window/README.md
@@ -30,7 +30,7 @@
| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
| 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[Sliding Window](../sliding-window/README.md)] | Hard |
| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
-| 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
+| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard |
| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
diff --git a/tag/sort/README.md b/tag/sort/README.md
index 3ae174849..469d3f3fb 100644
--- a/tag/sort/README.md
+++ b/tag/sort/README.md
@@ -9,6 +9,7 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
+| 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
| 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium |
| 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy |
| 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] | Hard |
diff --git a/tag/stack/README.md b/tag/stack/README.md
index 238b0b4da..23154cbab 100644
--- a/tag/stack/README.md
+++ b/tag/stack/README.md
@@ -9,67 +9,3 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
-| 1703 | [得到连续 K 个 1 的最少相邻交换次数](../../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | [[栈](../stack/README.md)] | Hard |
-| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium |
-| 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] | Easy |
-| 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy |
-| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium |
-| 1441 | [用栈操作构建数组](../../problems/build-an-array-with-stack-operations) | [[栈](../stack/README.md)] | Easy |
-| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium |
-| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium |
-| 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium |
-| 1209 | [删除字符串中的所有相邻重复项 II](../../problems/remove-all-adjacent-duplicates-in-string-ii) | [[栈](../stack/README.md)] | Medium |
-| 1190 | [反转每对括号间的子串](../../problems/reverse-substrings-between-each-pair-of-parentheses) | [[栈](../stack/README.md)] | Medium |
-| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 1124 | [表现良好的最长时间段](../../problems/longest-well-performing-interval) | [[栈](../stack/README.md)] | Medium |
-| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium |
-| 1063 | [有效子数组的数目](../../problems/number-of-valid-subarrays) 🔒 | [[栈](../stack/README.md)] | Hard |
-| 1047 | [删除字符串中的所有相邻重复项](../../problems/remove-all-adjacent-duplicates-in-string) | [[栈](../stack/README.md)] | Easy |
-| 1021 | [删除最外层的括号](../../problems/remove-outermost-parentheses) | [[栈](../stack/README.md)] | Easy |
-| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] | Medium |
-| 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium |
-| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard |
-| 946 | [验证栈序列](../../problems/validate-stack-sequences) | [[栈](../stack/README.md)] | Medium |
-| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium |
-| 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium |
-| 901 | [股票价格跨度](../../problems/online-stock-span) | [[栈](../stack/README.md)] | Medium |
-| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Hard |
-| 880 | [索引处的解码字符串](../../problems/decoded-string-at-index) | [[栈](../stack/README.md)] | Medium |
-| 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium |
-| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy |
-| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard |
-| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard |
-| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 735 | [行星碰撞](../../problems/asteroid-collision) | [[栈](../stack/README.md)] | Medium |
-| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard |
-| 682 | [棒球比赛](../../problems/baseball-game) | [[栈](../stack/README.md)] | Easy |
-| 636 | [函数的独占时间](../../problems/exclusive-time-of-functions) | [[栈](../stack/README.md)] | Medium |
-| 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard |
-| 503 | [下一个更大元素 II](../../problems/next-greater-element-ii) | [[栈](../stack/README.md)] | Medium |
-| 496 | [下一个更大元素 I](../../problems/next-greater-element-i) | [[栈](../stack/README.md)] | Easy |
-| 456 | [132模式](../../problems/132-pattern) | [[栈](../stack/README.md)] | Medium |
-| 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium |
-| 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium |
-| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium |
-| 331 | [验证二叉树的前序序列化](../../problems/verify-preorder-serialization-of-a-binary-tree) | [[栈](../stack/README.md)] | Medium |
-| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium |
-| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard |
-| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium |
-| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy |
-| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium |
-| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy |
-| 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[数学](../math/README.md)] | Hard |
-| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium |
-| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy |
-| 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] | Medium |
-| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium |
-| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium |
-| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
-| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
-| 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard |
-| 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium |
-| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
-| 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy |
diff --git a/tag/string/README.md b/tag/string/README.md
index 9549c364f..d7176ade4 100644
--- a/tag/string/README.md
+++ b/tag/string/README.md
@@ -9,6 +9,8 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
+| 1781 | [所有子字符串美丽值之和](../../problems/sum-of-beauty-of-all-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium |
+| 1773 | [统计匹配检索规则的物品数量](../../problems/count-items-matching-a-rule) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy |
| 1768 | [交替合并字符串](../../problems/merge-strings-alternately) | [[字符串](../string/README.md)] | Easy |
| 1763 | [最长的美好子字符串](../../problems/longest-nice-substring) | [[字符串](../string/README.md)] | Easy |
| 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium |
diff --git a/tag/tags.json b/tag/tags.json
index a01a1babe..a013ad07a 100644
--- a/tag/tags.json
+++ b/tag/tags.json
@@ -29,16 +29,16 @@
"Slug": "depth-first-search",
"TranslatedName": "深度优先搜索"
},
- {
- "Name": "Hash Table",
- "Slug": "hash-table",
- "TranslatedName": "哈希表"
- },
{
"Name": "Greedy",
"Slug": "greedy",
"TranslatedName": "贪心算法"
},
+ {
+ "Name": "Hash Table",
+ "Slug": "hash-table",
+ "TranslatedName": "哈希表"
+ },
{
"Name": "Binary Search",
"Slug": "binary-search",
@@ -94,16 +94,16 @@
"Slug": "heap",
"TranslatedName": "堆"
},
- {
- "Name": "Union Find",
- "Slug": "union-find",
- "TranslatedName": "并查集"
- },
{
"Name": "Recursion",
"Slug": "recursion",
"TranslatedName": "递归"
},
+ {
+ "Name": "Union Find",
+ "Slug": "union-find",
+ "TranslatedName": "并查集"
+ },
{
"Name": "Sliding Window",
"Slug": "sliding-window",
diff --git a/tag/tree/README.md b/tag/tree/README.md
index b7e90ec33..838c82596 100644
--- a/tag/tree/README.md
+++ b/tag/tree/README.md
@@ -9,161 +9,3 @@
| # | 题目 | 标签 | 难度 |
| :-: | - | - | :-: |
-| 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard |
-| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
-| 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] | Hard |
-| 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1660 | [纠正二叉树](../../problems/correct-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium |
-| 1650 | [二叉树的最近公共祖先 III](../../problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [[树](../tree/README.md)] | Medium |
-| 1644 | [二叉树的最近公共祖先 II](../../problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [[树](../tree/README.md)] | Medium |
-| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium |
-| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] | Medium |
-| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
-| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium |
-| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard |
-| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium |
-| 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1516 | [移动 N 叉树的子树](../../problems/move-sub-tree-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard |
-| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy |
-| 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1430 | [判断给定的序列是否是二叉树从根到叶的路径](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium |
-| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 1325 | [删除给定值的叶子节点](../../problems/delete-leaves-with-a-given-value) | [[树](../tree/README.md)] | Medium |
-| 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium |
-| 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] | Medium |
-| 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
-| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
-| 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] | Medium |
-| 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1104 | [二叉树寻路](../../problems/path-in-zigzag-labelled-binary-tree) | [[树](../tree/README.md)] [[数学](../math/README.md)] | Medium |
-| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard |
-| 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] | Easy |
-| 1008 | [前序遍历构造二叉搜索树](../../problems/construct-binary-search-tree-from-preorder-traversal) | [[树](../tree/README.md)] | Medium |
-| 998 | [最大二叉树 II](../../problems/maximum-binary-tree-ii) | [[树](../tree/README.md)] | Medium |
-| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy |
-| 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard |
-| 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard |
-| 965 | [单值二叉树](../../problems/univalued-binary-tree) | [[树](../tree/README.md)] | Easy |
-| 958 | [二叉树的完全性检验](../../problems/check-completeness-of-a-binary-tree) | [[树](../tree/README.md)] | Medium |
-| 951 | [翻转等价二叉树](../../problems/flip-equivalent-binary-trees) | [[树](../tree/README.md)] | Medium |
-| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy |
-| 919 | [完全二叉树插入器](../../problems/complete-binary-tree-inserter) | [[树](../tree/README.md)] | Medium |
-| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy |
-| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] | Medium |
-| 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy |
-| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
-| 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard |
-| 814 | [二叉树剪枝](../../problems/binary-tree-pruning) | [[树](../tree/README.md)] | Medium |
-| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy |
-| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 742 | [二叉树最近的叶节点](../../problems/closest-leaf-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium |
-| 701 | [二叉搜索树中的插入操作](../../problems/insert-into-a-binary-search-tree) | [[树](../tree/README.md)] | Medium |
-| 700 | [二叉搜索树中的搜索](../../problems/search-in-a-binary-search-tree) | [[树](../tree/README.md)] | Easy |
-| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard |
-| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium |
-| 671 | [二叉树中第二小的节点](../../problems/second-minimum-node-in-a-binary-tree) | [[树](../tree/README.md)] | Easy |
-| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 666 | [路径总和 IV](../../problems/path-sum-iv) 🔒 | [[树](../tree/README.md)] | Medium |
-| 663 | [均匀树划分](../../problems/equal-tree-partition) 🔒 | [[树](../tree/README.md)] | Medium |
-| 662 | [二叉树最大宽度](../../problems/maximum-width-of-binary-tree) | [[树](../tree/README.md)] | Medium |
-| 655 | [输出二叉树](../../problems/print-binary-tree) | [[树](../tree/README.md)] | Medium |
-| 654 | [最大二叉树](../../problems/maximum-binary-tree) | [[树](../tree/README.md)] | Medium |
-| 653 | [两数之和 IV - 输入 BST](../../problems/two-sum-iv-input-is-a-bst) | [[树](../tree/README.md)] | Easy |
-| 652 | [寻找重复的子树](../../problems/find-duplicate-subtrees) | [[树](../tree/README.md)] | Medium |
-| 637 | [二叉树的层平均值](../../problems/average-of-levels-in-binary-tree) | [[树](../tree/README.md)] | Easy |
-| 623 | [在二叉树中增加一行](../../problems/add-one-row-to-tree) | [[树](../tree/README.md)] | Medium |
-| 617 | [合并二叉树](../../problems/merge-two-binary-trees) | [[树](../tree/README.md)] | Easy |
-| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Easy |
-| 590 | [N叉树的后序遍历](../../problems/n-ary-tree-postorder-traversal) | [[树](../tree/README.md)] | Easy |
-| 589 | [N叉树的前序遍历](../../problems/n-ary-tree-preorder-traversal) | [[树](../tree/README.md)] | Easy |
-| 582 | [杀死进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium |
-| 572 | [另一个树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] | Easy |
-| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy |
-| 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy |
-| 549 | [二叉树中最长的连续序列](../../problems/binary-tree-longest-consecutive-sequence-ii) 🔒 | [[树](../tree/README.md)] | Medium |
-| 545 | [二叉树的边界](../../problems/boundary-of-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium |
-| 543 | [二叉树的直径](../../problems/diameter-of-binary-tree) | [[树](../tree/README.md)] | Easy |
-| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium |
-| 530 | [二叉搜索树的最小绝对差](../../problems/minimum-absolute-difference-in-bst) | [[树](../tree/README.md)] | Easy |
-| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
-| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
-| 510 | [二叉搜索树中的中序后继 II](../../problems/inorder-successor-in-bst-ii) 🔒 | [[树](../tree/README.md)] | Medium |
-| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
-| 501 | [二叉搜索树中的众数](../../problems/find-mode-in-binary-search-tree) | [[树](../tree/README.md)] | Easy |
-| 450 | [删除二叉搜索树中的节点](../../problems/delete-node-in-a-bst) | [[树](../tree/README.md)] | Medium |
-| 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] | Medium |
-| 437 | [路径总和 III](../../problems/path-sum-iii) | [[树](../tree/README.md)] | Medium |
-| 431 | [将 N 叉树编码为二叉树](../../problems/encode-n-ary-tree-to-binary-tree) 🔒 | [[树](../tree/README.md)] | Hard |
-| 429 | [N 叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
-| 428 | [序列化和反序列化 N 叉树](../../problems/serialize-and-deserialize-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard |
-| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium |
-| 404 | [左叶子之和](../../problems/sum-of-left-leaves) | [[树](../tree/README.md)] | Easy |
-| 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 333 | [最大 BST 子树](../../problems/largest-bst-subtree) 🔒 | [[树](../tree/README.md)] | Medium |
-| 298 | [二叉树最长连续序列](../../problems/binary-tree-longest-consecutive-sequence) 🔒 | [[树](../tree/README.md)] | Medium |
-| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard |
-| 285 | [二叉搜索树中的顺序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] | Medium |
-| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard |
-| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Easy |
-| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy |
-| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium |
-| 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] | Medium |
-| 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] | Medium |
-| 235 | [二叉搜索树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](../tree/README.md)] | Easy |
-| 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium |
-| 226 | [翻转二叉树](../../problems/invert-binary-tree) | [[树](../tree/README.md)] | Easy |
-| 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium |
-| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium |
-| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium |
-| 156 | [上下翻转二叉树](../../problems/binary-tree-upside-down) 🔒 | [[树](../tree/README.md)] | Medium |
-| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium |
-| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium |
-| 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard |
-| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
-| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium |
-| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy |
-| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy |
-| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy |
-| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy |
-| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
-| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium |
-| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium |
-| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy |
-| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
-| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium |
-| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy |
-| 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy |
-| 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard |
-| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium |
-| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |
-| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium |
diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md
index 461770ab9..869c5d53e 100644
--- a/tag/two-pointers/README.md
+++ b/tag/two-pointers/README.md
@@ -47,7 +47,7 @@
| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium |
| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium |
| 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[双指针](../two-pointers/README.md)] | Medium |
-| 457 | [环形数组循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium |
+| 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium |
| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |
| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium |
| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy |