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:

### 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:

+ -
-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:

+ + + ### 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:

- -
    -
  1. board.length == board[i].length == 8
  2. -
  3. board[i][j] is either 'R', '.', 'B', or 'p'
  4. +
+ ### 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:
-

    -
  1. The range of node's value is in the range of 32-bit signed integer.
  2. -
-

+

 

+

Constraints:

+ + ### 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:

### 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:

-

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:

+ + + ### 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] = 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. +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:

    + + ### 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):

    ### 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.

    -

     

    + -

    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:

    ### 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:

    - -
      -
    1. All the strings in the input will only contain lower-case letters.
    2. -
    3. The size of the dictionary won't exceed 1,000.
    4. -
    5. The length of all the strings in the input won't exceed 1,000.
    6. -
    - -

     

    +

    Constraints:

    + + ### 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:

    + + + +### 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:

    + + ### 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 @@ 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:

     

    -

    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:

    -
    -

     

    -
    - ### 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:

    +

     

    +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:

    + + ### 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:

    + + + +### 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:

    + + ### 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:

    - -
      -
    1. 3 <= A.length <= 50
    2. -
    3. 1 <= A[i] <= 100
    4. -
    -
    -
    -
    + ### 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:

    ### 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:

    - -
      -
    1. You must do this in-place without making a copy of the array.
    2. -
    3. Minimize the total number of operations.
    4. -
    +

    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:

    + + + +

     

    +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:

    @@ -49,7 +49,7 @@

    Constraints:

     

    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.

    + + + +

     

    +

    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:

    ### 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:

    + + + +### 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:

    -

    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:

    + + -

    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 @@

     

    -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:

    -

    (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:

    + + + ### 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:

    ### 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: L0L1→…→Ln-1Ln,
    -reorder it to: L0LnL1Ln-1L2Ln-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:

    + + + ### 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.

    + + +

    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:

    ### 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: -
      -
    1. The string consists of lower English letters only.
    2. -
    3. Length of the given string and k will in the range [1, 10000]
    4. -
    + ### 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. -

    + ### 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:

    - - - -

     

    +

    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:

    + + ### 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:

     

    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:

    -
      -
    1. 2 <= A.length <= 20000
    2. -
    3. A.length % 2 == 0
    4. -
    5. 0 <= A[i] <= 1000
    6. -
    +
    +Input: nums = [2,3]
    +Output: [2,3]
    +
    -

     

    -
    +

    Constraints:

    + + ### 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:

    - +
    +Input: nums = [3,1]
    +Output: false
    +

     

    +

    Constraints:

    + + ### 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 countcount[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:

     

    @@ -33,12 +35,12 @@

     

    Constraints:

    -
      +
    +
  • 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: - -

    -

      -
    1. 'A' : Absent.
    2. -
    3. 'L' : Late.
    4. -
    5. 'P' : Present.
    6. -
    -

    - -

    -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 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
    -
    -

    + ### 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:

    -

    -

      -
    1. 'A' : Absent.
    2. -
    3. 'L' : Late.
    4. -
    5. 'P' : Present.
    6. -
    -

    + -

    -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.

    + + + +

    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:

    + + + +### 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
    -
    -
    -
    + ### 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. 1 <= K <= 100
    2. -
    3. 1 <= N <= 10000
    4. -
    -
    -
    -
    + ### 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:

    ### 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. 1 is typically treated as an ugly number.
    2. -
    3. n does not exceed 1690.
    4. -
    +
    +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. 1 is typically treated as an ugly number.
    2. -
    3. Input is within the 32-bit signed integer range: [−231,  231 − 1].
    4. -
    +
    +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.comalice 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.)

    + -

    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.

    + +

    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:

    -
    ### 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:

    - -
      +
    - -
    -
     
    -
    +
  • 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:

    - - +

    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:

    + + ### 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:

    - - +

    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:

    + + + ### 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 @@ ### 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 |