From ce6b5442cd7b9f7bc216be589e4ab481e67642dc Mon Sep 17 00:00:00 2001
From: Shuo Reversing an integer means to reverse all its digits. Given an integer Example 1: Example 2: Example 3: Constraints: You are given two positive integers Since the product may be very large, you will abbreviate it following these steps: Return a string denoting the abbreviated product of all integers in the inclusive range Example 1: Example 2: Example 3: Constraints: Example 4: Constraints: You are given a 0-indexed string Return the modified string after the spaces have been added. Example 1: Example 2: Example 3: Constraints: Example 3: Example 4: Constraints: You are given a 0-indexed binary array The division score of an index Return all distinct indices that have the highest possible division score. You may return the answer in any order. Example 1: Example 2: Example 3: Constraints: Given two binary search trees Return a list containing all the integers from both trees sorted in ascending order. Given two binary search trees Example 1: Example 2: Example 3: Example 4: Example 5: Constraints: Given the array Given the array Return the minimum total distance between each house and its nearest mailbox. Return the minimum total distance between each house and its nearest mailbox. The answer is guaranteed to fit in a 32-bit signed integer. The test cases are generated so that the answer fits in a 32-bit integer. Example 1: Example 2: Example 3: Example 4: Constraints: Given an array of unique integers You are given an array of unique integers Return the average salary of employees excluding the minimum and maximum salary. Return the average salary of employees excluding the minimum and maximum salary. Answers within Example 1: Example 2: Example 3: Example 4: If there are multiple valid answers return any of them. If it is impossible to avoid flood return an empty array. Example 4: Example 5: Constraints: Example 3: Example 4: Follow up: Could you do it in one-pass, using only A delivery company wants to build a new service centre in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new centre in a position such that the sum of the euclidean distances to all customers is minimum. A delivery company wants to build a new service center in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new center in a position such that the sum of the euclidean distances to all customers is minimum. Given an array In other words, you need to choose the position of the service centre In other words, you need to choose the position of the service center Answers within Answers within Example 1: Example 3: Example 4: Example 5: Constraints: Example 4: Constraints: Example 4: Example 5: Constraints: Example 3: Example 4: Constraints: Given an array You are given an array Build the In each iteration, you will read a number from Build the Return the operations to build the target array. You are guaranteed that the answer is unique. Return a list of the operations needed to build Example 1: Example 4: You are given a string Return the capitalized Example 1: Example 2: Example 3: Constraints: There is a car with You are given the integer You are given the integer Return Example 3: Example 4: Constraints: Example 1: Example 2: Example 4: Example 5: Constraints: Example 1: Example 2: Example 3: Example 2: Example 4: Example 3: Example 5: A parentheses string is a non-empty string consisting only of You are given a parentheses string Return Example 1: Example 2: Example 3: Constraints: Given a binary string Return Given a binary string Example 1: Example 2: Example 3: Example 4: Example 3: Example 5: Example 4: Example 5: Constraints: Given a string Example 1: Example 2: Example 3: Constraints: Example 4: Example 5: Constraints: Example 4: Example 5: Constraints: Given an array of integers We want to divide the array into exactly We want to divide the array into exactly Return True If you can find a way to do that or False otherwise. Return Example 1: Example 4: Example 5: Constraints: An Given an Example 1: Example 2: Constraints: Example 4: Constraints: Example 4: Constraints: Given two strings Given two strings For example, applying the operation on the underlined substring in Return Return A substring is a contiguous sequence of characters within a string. A substring is a contiguous sequence of characters within a string. Example 1: Example 4: Constraints: Given a You are given a You have two robots that can collect cherries for you, Robot #1 is located at the top-left corner (0,0) , and Robot #2 is located at the top-right corner (0, cols-1) of the grid. You have two robots that can collect cherries for you: Return the maximum number of cherries collection using both robots by following the rules below: Return the maximum number of cherries collection using both robots by following the rules below: Example 1: Example 2: Example 3: Example 4: Constraints: Given a circle represented as ( You are given a circle represented as Return True if the circle and rectangle are overlapped otherwise return False. In other words, check if there are any point (xi, yi) such that belongs to the circle and the rectangle at the same time. Return Example 1: Example 2: Example 3: Example 4: Constraints: Example 4: Constraints: Example 4: Example 5: Constraints: Example 3: Example 4: Example 5: Constraints:
+
+
+2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained.num, reverse num to get reversed1, then reverse reversed1 to get reversed2. Return true if reversed2 equals num. Otherwise return false.
+Input: num = 526
+Output: true
+Explanation: Reverse num to get 625, then reverse 625 to get 526, which equals num.
+
+
+
+Input: num = 1800
+Output: false
+Explanation: Reverse num to get 81, then reverse 81 to get 18, which does not equal num.
+
+
+
+Input: num = 0
+Output: true
+Explanation: Reverse num to get 0, then reverse 0 to get 0, which equals num.
+
+
+
+
+
+### Related Topics
+ [[Math](../../tag/math/README.md)]
+
+### Hints
+0 <= num <= 106Hint 1
+Other than the number 0 itself, any number that ends with 0 would lose some digits permanently when reversed.
+left and right with left <= right. Calculate the product of all integers in the inclusive range [left, right].
+
+
+C.
+
+
+ 3 trailing zeros in 1000, and there are 0 trailing zeros in 546.d. If d > 10, then express the product as <pre>...<suf> where <pre> denotes the first 5 digits of the product, and <suf> denotes the last 5 digits of the product after removing all trailing zeros. If d <= 10, we keep it unchanged.
+
+
+ 1234567654321 as 12345...54321, but 1234567 is represented as 1234567."<pre>...<suf>eC".
+
+
+ 12345678987600000 will be represented as "12345...89876e5".[left, right].
+Input: left = 1, right = 4
+Output: "24e0"
+Explanation: The product is 1 × 2 × 3 × 4 = 24.
+There are no trailing zeros, so 24 remains the same. The abbreviation will end with "e0".
+Since the number of digits is 2, which is less than 10, we do not have to abbreviate it further.
+Thus, the final representation is "24e0".
+
+
+
+Input: left = 2, right = 11
+Output: "399168e2"
+Explanation: The product is 39916800.
+There are 2 trailing zeros, which we remove to get 399168. The abbreviation will end with "e2".
+The number of digits after removing the trailing zeros is 6, so we do not abbreviate it further.
+Hence, the abbreviated product is "399168e2".
+
+
+
+Input: left = 371, right = 375
+Output: "7219856259e3"
+Explanation: The product is 7219856259000.
+
+
+
+
+
+### Related Topics
+ [[Math](../../tag/math/README.md)]
+
+### Hints
+1 <= left <= right <= 104Hint 1
+Calculating the number of trailing zeros, the last five digits, and the first five digits can all be done separately.
+Hint 2
+Use a prime factorization property to find the number of trailing zeros. Use modulo to find the last 5 digits. Use a logarithm property to find the first 5 digits.
+Hint 3
+The number of trailing zeros C is nothing but the number of times the product is completely divisible by 10. Since 2 and 5 are the only prime factors of 10, C will be equal to the minimum number of times 2 or 5 appear in the prime factorization of the product.
+Hint 4
+Iterate through the integers from left to right. For every integer, keep dividing it by 2 as long as it is divisible by 2 and C occurrences of 2 haven't been removed in total. Repeat this process for 5. Finally, multiply the integer under modulo of 10^5 with the product obtained till now to obtain the last five digits.
+Hint 5
+The product P can be represented as P=10^(x+y) where x is the integral part and y is the fractional part of x+y. Using the property "if S = A * B, then log(S) = log(A) + log(B)", we can write x+y = log_10(P) = sum(log_10(i)) for each integer i in [left, right]. Once we obtain the sum, the first five digits can be represented as floor(10^(y+4)).
+
-Input: rungs = [5], dist = 10
-Output: 0
-Explanation:
-This ladder can be climbed without adding additional rungs.
-
-
rungs is strictly increasing.Hint 1
diff --git a/problems/add-two-numbers/README.md b/problems/add-two-numbers/README.md
index 5d07d51cf..4b8b6c228 100644
--- a/problems/add-two-numbers/README.md
+++ b/problems/add-two-numbers/README.md
@@ -1,8 +1,8 @@
-
-
-
+
+
+
[< Previous](../two-sum "Two Sum")
diff --git a/problems/adding-spaces-to-a-string/README.md b/problems/adding-spaces-to-a-string/README.md
new file mode 100644
index 000000000..2239ba4fd
--- /dev/null
+++ b/problems/adding-spaces-to-a-string/README.md
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+[< Previous](../find-first-palindromic-string-in-the-array "Find First Palindromic String in the Array")
+
+[Next >](../number-of-smooth-descent-periods-of-a-stock "Number of Smooth Descent Periods of a Stock")
+
+## [2109. Adding Spaces to a String (Medium)](https://leetcode.com/problems/adding-spaces-to-a-string "向字符串添加空格")
+
+s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index.
+
+
+s = "EnjoyYourCoffee" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at indices 5 and 9 respectively. Thus, we obtain "Enjoy Your Coffee".
+Input: s = "LeetcodeHelpsMeLearn", spaces = [8,13,15]
+Output: "Leetcode Helps Me Learn"
+Explanation:
+The indices 8, 13, and 15 correspond to the underlined characters in "LeetcodeHelpsMeLearn".
+We then place spaces before those characters.
+
+
+
+Input: s = "icodeinpython", spaces = [1,5,7,9]
+Output: "i code in py thon"
+Explanation:
+The indices 1, 5, 7, and 9 correspond to the underlined characters in "icodeinpython".
+We then place spaces before those characters.
+
+
+
+Input: s = "spacing", spaces = [0,1,2,3,4,5,6]
+Output: " s p a c i n g"
+Explanation:
+We are also able to place spaces before the first character of the string.
+
+
+
+
+
+### Related Topics
+ [[Array](../../tag/array/README.md)]
+ [[String](../../tag/string/README.md)]
+ [[Simulation](../../tag/simulation/README.md)]
+
+### Hints
+1 <= s.length <= 3 * 105s consists only of lowercase and uppercase English letters.1 <= spaces.length <= 3 * 1050 <= spaces[i] <= s.length - 1spaces are strictly increasing.Hint 1
+Create a new string, initially empty, as the modified string. Iterate through the original string and append each character of the original string to the new string. However, each time you reach a character that requires a space before it, append a space before appending the character.
+Hint 2
+Since the array of indices for the space locations is sorted, use a pointer to keep track of the next index to place a space. Only increment the pointer once a space has been appended.
+Hint 3
+Ensure that your append operation can be done in O(1).
+
-Input: keyName = ["john","john","john"], keyTime = ["23:58","23:59","00:01"]
-Output: []
-
-
-
-Input: keyName = ["leslie","leslie","leslie","clare","clare","clare","clare"], keyTime = ["13:00","13:20","14:00","18:00","18:51","19:30","19:49"]
-Output: ["clare","leslie"]
-
-
1 <= keyName.length, keyTime.length <= 105keyName.length == keyTime.lengthkeyTime[i] is in the format "HH:MM".keyTime[i] is in the format "HH:MM".[keyName[i], keyTime[i]] is unique.1 <= keyName[i].length <= 10keyName[i] contains only lowercase English letters.nums of length n. nums can be divided at index i (where 0 <= i <= n) into two arrays (possibly empty) numsleft and numsright:
+
+
+numsleft has all the elements of nums between index 0 and i - 1 (inclusive), while numsright has all the elements of nums between index i and n - 1 (inclusive).i == 0, numsleft is empty, while numsright has all the elements of nums.i == n, numsleft has all the elements of nums, while numsright is empty.i is the sum of the number of 0's in numsleft and the number of 1's in numsright.
+Input: nums = [0,0,1,0]
+Output: [2,4]
+Explanation: Division at index
+- 0: numsleft is []. numsright is [0,0,1,0]. The score is 0 + 1 = 1.
+- 1: numsleft is [0]. numsright is [0,1,0]. The score is 1 + 1 = 2.
+- 2: numsleft is [0,0]. numsright is [1,0]. The score is 2 + 1 = 3.
+- 3: numsleft is [0,0,1]. numsright is [0]. The score is 2 + 0 = 2.
+- 4: numsleft is [0,0,1,0]. numsright is []. The score is 3 + 0 = 3.
+Indices 2 and 4 both have the highest possible division score 3.
+Note the answer [4,2] would also be accepted.
+
+
+Input: nums = [0,0,0]
+Output: [3]
+Explanation: Division at index
+- 0: numsleft is []. numsright is [0,0,0]. The score is 0 + 0 = 0.
+- 1: numsleft is [0]. numsright is [0,0]. The score is 1 + 0 = 1.
+- 2: numsleft is [0,0]. numsright is [0]. The score is 2 + 0 = 2.
+- 3: numsleft is [0,0,0]. numsright is []. The score is 3 + 0 = 3.
+Only index 3 has the highest possible division score 3.
+
+
+
+Input: nums = [1,1]
+Output: [0]
+Explanation: Division at index
+- 0: numsleft is []. numsright is [1,1]. The score is 0 + 2 = 2.
+- 1: numsleft is [1]. numsright is [1]. The score is 0 + 1 = 1.
+- 2: numsleft is [1,1]. numsright is []. The score is 0 + 0 = 0.
+Only index 0 has the highest possible division score 2.
+
+
+
+
+
+### Related Topics
+ [[Array](../../tag/array/README.md)]
+
+### Hints
+n == nums.length1 <= n <= 105nums[i] is either 0 or 1.Hint 1
+When you iterate the array, maintain the number of zeros and ones on the left side. Can you quickly calculate the number of ones on the right side?
+Hint 2
+The number of ones on the right side equals the number of ones in the whole array minus the number of ones on the left side.
+Hint 3
+Alternatively, you can quickly calculate it by using a prefix sum array.
+root1 and root2.root1 and root2, return a list containing all the integers from both trees sorted in ascending order.
-Input: root1 = [0,-10,10], root2 = [5,1,7,0,2]
-Output: [-10,0,0,1,2,5,7,10]
-
-
-
-Input: root1 = [], root2 = [5,1,7,0,2]
-Output: [0,1,2,5,7]
-
-
-
-Input: root1 = [0,-10,10], root2 = []
-Output: [-10,0,10]
-
-
-
Input: root1 = [1,null,8], root2 = [8,1]
@@ -55,8 +32,8 @@
-
### Related Topics
diff --git a/problems/all-oone-data-structure/README.md b/problems/all-oone-data-structure/README.md
index c4c565fc7..b1bf3b3fc 100644
--- a/problems/all-oone-data-structure/README.md
+++ b/problems/all-oone-data-structure/README.md
@@ -1,8 +1,8 @@
-
-
-
+
+
+
[< Previous](../encode-n-ary-tree-to-binary-tree "Encode N-ary Tree to Binary Tree")
@@ -55,7 +55,7 @@ allOne.getMinKey(); // return "leet"
### Related Topics
- [[Design](../../tag/design/README.md)]
[[Hash Table](../../tag/hash-table/README.md)]
[[Linked List](../../tag/linked-list/README.md)]
+ [[Design](../../tag/design/README.md)]
[[Doubly-Linked List](../../tag/doubly-linked-list/README.md)]
diff --git a/problems/all-possible-full-binary-trees/README.md b/problems/all-possible-full-binary-trees/README.md
index 7d2cba86f..663028786 100644
--- a/problems/all-possible-full-binary-trees/README.md
+++ b/problems/all-possible-full-binary-trees/README.md
@@ -40,8 +40,8 @@
### Related Topics
+ [[Dynamic Programming](../../tag/dynamic-programming/README.md)]
[[Tree](../../tag/tree/README.md)]
[[Recursion](../../tag/recursion/README.md)]
[[Memoization](../../tag/memoization/README.md)]
- [[Dynamic Programming](../../tag/dynamic-programming/README.md)]
[[Binary Tree](../../tag/binary-tree/README.md)]
diff --git a/problems/allocate-mailboxes/README.md b/problems/allocate-mailboxes/README.md
index 5d982f082..b0bd29e7e 100644
--- a/problems/allocate-mailboxes/README.md
+++ b/problems/allocate-mailboxes/README.md
@@ -1,8 +1,8 @@
-
-
-
+
+
+
[< Previous](../find-two-non-overlapping-sub-arrays-each-with-target-sum "Find Two Non-overlapping Sub-arrays Each With Target Sum")
@@ -11,58 +11,38 @@
## [1478. Allocate Mailboxes (Hard)](https://leetcode.com/problems/allocate-mailboxes "安排邮筒")
-5000 nodes.[-10^5, 10^5].[0, 5000].-105 <= Node.val <= 105houses and an integer k. where houses[i] is the location of the ith house along a street, your task is to allocate k mailboxes in the street.houses where houses[i] is the location of the ith house along a street and an integer k, allocate k mailboxes in the street.
Input: houses = [1,4,8,10,20], k = 3
Output: 5
-Explanation: Allocate mailboxes in position 3, 9 and 20.
+Explanation: Allocate mailboxes in position 3, 9 and 20.
Minimum total distance from each houses to nearest mailboxes is |3-1| + |4-3| + |9-8| + |10-9| + |20-20| = 5

Input: houses = [2,3,5,12,18], k = 2
Output: 9
-Explanation: Allocate mailboxes in position 3 and 14.
+Explanation: Allocate mailboxes in position 3 and 14.
Minimum total distance from each houses to nearest mailboxes is |2-3| + |3-3| + |5-3| + |12-14| + |18-14| = 9.
-
-Input: houses = [7,4,6,1], k = 1
-Output: 8
-
-
-
-Input: houses = [3,6,14,10], k = 4
-Output: 0
-
-
-
### Related Topics
diff --git a/problems/amount-of-new-area-painted-each-day/README.md b/problems/amount-of-new-area-painted-each-day/README.md
new file mode 100644
index 000000000..7af517b36
--- /dev/null
+++ b/problems/amount-of-new-area-painted-each-day/README.md
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+[< Previous](../groups-of-strings "Groups of Strings")
+
+[Next >](../order-two-columns-independently "Order Two Columns Independently")
+
+## [2158. Amount of New Area Painted Each Day (Hard)](https://leetcode.com/problems/amount-of-new-area-painted-each-day "")
+
+
+
+### Related Topics
+ [[Segment Tree](../../tag/segment-tree/README.md)]
+ [[Array](../../tag/array/README.md)]
+ [[Ordered Set](../../tag/ordered-set/README.md)]
+
+### Hints
+n == houses.length1 <= n <= 1001 <= houses[i] <= 10^41 <= k <= nhouses contain unique integers.1 <= k <= houses.length <= 1001 <= houses[i] <= 104houses are unique.Hint 1
+What’s a good way to keep track of intervals that you have already painted?
+Hint 2
+Create an array of all 1’s, and when you have painted an interval, set the values in that interval to 0.
+Hint 3
+Using this array, how can you quickly calculate the amount of new area that you paint on a given day?
+Hint 4
+Calculate the sum of the new array in the interval that you paint.
+[5,9,3,7]. This can be
[[Array](../../tag/array/README.md)]
[[Sorting](../../tag/sorting/README.md)]
-### Similar Questions
- 1. [Arithmetic Slices](../arithmetic-slices) (Medium)
- 1. [Can Make Arithmetic Progression From Sequence](../can-make-arithmetic-progression-from-sequence) (Easy)
-
### Hints
Hint 1
diff --git a/problems/armstrong-number/README.md b/problems/armstrong-number/README.md
index 2a5aef613..6393d60cd 100644
--- a/problems/armstrong-number/README.md
+++ b/problems/armstrong-number/README.md
@@ -1,8 +1,8 @@
-
-
-
+
+
+
[< Previous](../largest-unique-number "Largest Unique Number")
diff --git a/problems/available-captures-for-rook/README.md b/problems/available-captures-for-rook/README.md
index 6c4c5b748..d1375f510 100644
--- a/problems/available-captures-for-rook/README.md
+++ b/problems/available-captures-for-rook/README.md
@@ -1,8 +1,8 @@
-
-
-
+
+
+
[< Previous](../maximum-binary-tree-ii "Maximum Binary Tree II")
diff --git a/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md b/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md
index 1dcd53d41..239269d1b 100644
--- a/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md
+++ b/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md
@@ -1,8 +1,8 @@
-
-
-
+
+
+
[< Previous](../clone-n-ary-tree "Clone N-ary Tree")
@@ -11,9 +11,9 @@
## [1491. Average Salary Excluding the Minimum and Maximum Salary (Easy)](https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary "去掉最低工资和最高工资后的工资平均值")
-salary where salary[i] is the salary of the employee i.salary where salary[i] is the salary of the ith employee.10-5 of the actual answer will be accepted.
Input: salary = [4000,3000,1000,2000]
Output: 2500.00000
-Explanation: Minimum salary and maximum salary are 1000 and 4000 respectively.
-Average salary excluding minimum and maximum salary is (2000+3000)/2= 2500
+Explanation: Minimum salary and maximum salary are 1000 and 4000 respectively.
+Average salary excluding minimum and maximum salary is (2000+3000) / 2 = 2500
Input: salary = [1000,2000,3000]
Output: 2000.00000
-Explanation: Minimum salary and maximum salary are 1000 and 3000 respectively.
-Average salary excluding minimum and maximum salary is (2000)/1= 2000
-
-
-
-Input: salary = [6000,5000,4000,3000,2000,1000]
-Output: 3500.00000
-
-
-
-Input: salary = [8000,9000,2000,3000,6000,1000]
-Output: 4750.00000
+Explanation: Minimum salary and maximum salary are 1000 and 3000 respectively.
+Average salary excluding minimum and maximum salary is (2000) / 1 = 2000
### Related Topics
diff --git a/problems/average-waiting-time/README.md b/problems/average-waiting-time/README.md
index ef5e69e93..d2cba9701 100644
--- a/problems/average-waiting-time/README.md
+++ b/problems/average-waiting-time/README.md
@@ -61,9 +61,6 @@ So the average waiting time = (2 + 6 + 4 + 1) / 4 = 3.25.
[[Array](../../tag/array/README.md)]
[[Simulation](../../tag/simulation/README.md)]
-### Similar Questions
- 1. [Average Height of Buildings in Each Segment](../average-height-of-buildings-in-each-segment) (Medium)
-
### Hints
3 <= salary.length <= 10010^3 <= salary[i] <= 10^6salary[i] is unique.10^-5 of the actual value will be accepted as correct.1000 <= salary[i] <= 106salary are unique.Hint 1
diff --git a/problems/avoid-flood-in-the-city/README.md b/problems/avoid-flood-in-the-city/README.md
index a691b24b6..fdd8339ce 100644
--- a/problems/avoid-flood-in-the-city/README.md
+++ b/problems/avoid-flood-in-the-city/README.md
@@ -25,7 +25,7 @@
ans.length == rains.lengthans[i] == -1 if rains[i] > 0.ans[i] is the lake you choose to dry in the ith day if rains[i] == 0.ans[i] is the lake you choose to dry in the ith day if rains[i] == 0.
-Input: rains = [69,0,0,0,69]
-Output: [-1,69,1,1,-1]
-Explanation: Any solution on one of the forms [-1,69,x,y,-1], [-1,x,69,y,-1] or [-1,x,y,69,-1] is acceptable where 1 <= x,y <= 10^9
-
-
-
-Input: rains = [10,20,20]
-Output: []
-Explanation: It will rain over lake 20 two consecutive days. There is no chance to dry any lake.
-
-
-Input: s = "a##c", t = "#a#c"
-Output: true
-Explanation: Both s and t become "c".
-
-
-
Input: s = "a#c", t = "b"
Output: false
@@ -53,7 +45,7 @@
1 <= s.length, t.length <= 200s and t only contain lowercase letters and '#' characters.s and t only contain lowercase letters and '#' characters.O(1) extra memory and without modifying the values board?positions where positions[i] = [xi, yi] is the position of the ith customer on the map, return the minimum sum of the euclidean distances to all customers.[xcentre, ycentre] such that the following formula is minimized:[xcentre, ycentre] such that the following formula is minimized:
-10^-5 of the actual value will be accepted.10-5 of the actual value will be accepted.
-Input: positions = [[1,1]]
-Output: 0.00000
-
-
-
-Input: positions = [[1,1],[0,0],[2,0]]
-Output: 2.73205
-Explanation: At the first glance, you may think that locating the centre at [1, 0] will achieve the minimum sum, but locating it at [1, 0] will make the sum of distances = 3.
-Try to locate the centre at [1.0, 0.5773502711] you will see that the sum of distances is 2.73205.
-Be careful with the precision!
-
-
-
-Input: positions = [[0,1],[3,2],[4,5],[7,6],[8,9],[11,1],[2,12]]
-Output: 32.94036
-Explanation: You can use [4.3460852395, 4.9813795505] as the position of the centre.
-
-
-
### Related Topics
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 198700c20..aed420db4 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
@@ -43,13 +43,6 @@ Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are
Explanation: In this case, no transaction is done, i.e. max profit = 0.
-1 <= positions.length <= 501 <= positions.length <= 50positions[i].length == 20 <= positions[i][0], positions[i][1] <= 1000 <= xi, yi <= 100
-Input: prices = [1]
-Output: 0
-
-
-Input: n = 10
-Output: true
-Explanation: The binary representation of 10 is: 1010.
-
-
-Input: n = 3
-Output: false
-
-
-Input: palindrome = "aa"
-Output: "ab"
-
-
-Input: palindrome = "aba"
-Output: "abb"
-
-
target and an integer n. In each iteration, you will read a number from list = {1,2,3..., n}.target and an integer n.target array using the following operations:list = [1, 2, 3, ..., n].target array using the following operations:
-
-list, and push it in the array."Push": Reads a new element from the beginning list, and pushes it in the array."Pop": Deletes the last element of the array.target. The test cases are generated so that the answer is unique.
Input: target = [1,3], n = 3
Output: ["Push","Push","Pop","Push"]
-Explanation:
-Read number 1 and automatically push in the array -> [1]
+Explanation:
+Read number 1 and automatically push in the array -> [1]
Read number 2 and automatically push in the array then Pop it -> [1]
Read number 3 and automatically push in the array -> [1,3]
@@ -47,14 +49,7 @@ Read number 3 and automatically push in the array -> [1,3]
Input: target = [1,2], n = 4
Output: ["Push","Push"]
-Explanation: You only need to read the first 2 numbers and stop.
-
-
-
-Input: target = [2,3,4], n = 4
-Output: ["Push","Pop","Push","Push","Push"]
+Explanation: You only need to read the first 2 numbers and stop.
### Related Topics
- [[Stack](../../tag/stack/README.md)]
[[Array](../../tag/array/README.md)]
+ [[Stack](../../tag/stack/README.md)]
[[Simulation](../../tag/simulation/README.md)]
### Hints
diff --git a/problems/build-binary-expression-tree-from-infix-expression/README.md b/problems/build-binary-expression-tree-from-infix-expression/README.md
index fc0ee4558..ccb059a16 100644
--- a/problems/build-binary-expression-tree-from-infix-expression/README.md
+++ b/problems/build-binary-expression-tree-from-infix-expression/README.md
@@ -14,11 +14,15 @@
### Related Topics
+ [[String](../../tag/string/README.md)]
[[Stack](../../tag/stack/README.md)]
[[Tree](../../tag/tree/README.md)]
- [[String](../../tag/string/README.md)]
[[Binary Tree](../../tag/binary-tree/README.md)]
+### Similar Questions
+ 1. [Basic Calculator III](../basic-calculator-iii) (Hard)
+ 1. [Check If Two Expression Trees are Equivalent](../check-if-two-expression-trees-are-equivalent) (Medium)
+
### Hints
1 <= target.length <= 1001 <= target[i] <= n1 <= n <= 100target is strictly increasing.1 <= target[i] <= ntarget is strictly increasing.Hint 1
diff --git a/problems/build-the-equation/README.md b/problems/build-the-equation/README.md
new file mode 100644
index 000000000..1a035a2c2
--- /dev/null
+++ b/problems/build-the-equation/README.md
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+[< Previous](../abbreviating-the-product-of-a-range "Abbreviating the Product of a Range")
+
+[Next >](../a-number-after-a-double-reversal "A Number After a Double Reversal")
+
+## [2118. Build the Equation (Hard)](https://leetcode.com/problems/build-the-equation "")
+
+
+
+### Related Topics
+ [[Database](../../tag/database/README.md)]
diff --git a/problems/build-the-equation/mysql_schemas.sql b/problems/build-the-equation/mysql_schemas.sql
new file mode 100644
index 000000000..9cb986611
--- /dev/null
+++ b/problems/build-the-equation/mysql_schemas.sql
@@ -0,0 +1,5 @@
+Create table If Not Exists Terms (power int, factor int);
+Truncate table Terms;
+insert into Terms (power, factor) values ('2', '1');
+insert into Terms (power, factor) values ('1', '-4');
+insert into Terms (power, factor) values ('0', '2');
diff --git a/problems/burst-balloons/README.md b/problems/burst-balloons/README.md
index e2fb7335a..d8143c649 100644
--- a/problems/burst-balloons/README.md
+++ b/problems/burst-balloons/README.md
@@ -1,8 +1,8 @@
-
-
-
+
+
+
[< Previous](../sparse-matrix-multiplication "Sparse Matrix Multiplication")
@@ -39,7 +39,7 @@ coins = 3*1*5 + 3*5*8 + 1*3*8 + 1*8*1 = 167
diff --git a/problems/calculate-salaries/README.md b/problems/calculate-salaries/README.md
index 23f8246eb..9f0654cc5 100644
--- a/problems/calculate-salaries/README.md
+++ b/problems/calculate-salaries/README.md
@@ -1,8 +1,8 @@
-
-
-
+
+
+
[< Previous](../probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "Probability of a Two Boxes Having The Same Number of Distinct Balls")
diff --git a/problems/campus-bikes/README.md b/problems/campus-bikes/README.md
index ea7457295..6e99c5415 100644
--- a/problems/campus-bikes/README.md
+++ b/problems/campus-bikes/README.md
@@ -1,8 +1,8 @@
-
-
-
+
+
+
[< Previous](../confusing-number "Confusing Number")
diff --git a/problems/can-make-arithmetic-progression-from-sequence/README.md b/problems/can-make-arithmetic-progression-from-sequence/README.md
index 92f0cbc72..8ab8e871e 100644
--- a/problems/can-make-arithmetic-progression-from-sequence/README.md
+++ b/problems/can-make-arithmetic-progression-from-sequence/README.md
@@ -44,6 +44,9 @@
[[Array](../../tag/array/README.md)]
[[Sorting](../../tag/sorting/README.md)]
+### Similar Questions
+ 1. [Arithmetic Subarrays](../arithmetic-subarrays) (Medium)
+
### Hints
n == nums.length1 <= n <= 5001 <= n <= 3000 <= nums[i] <= 100Hint 1
diff --git a/problems/can-make-palindrome-from-substring/README.md b/problems/can-make-palindrome-from-substring/README.md
index e8a95283e..20ea8a9eb 100644
--- a/problems/can-make-palindrome-from-substring/README.md
+++ b/problems/can-make-palindrome-from-substring/README.md
@@ -51,14 +51,11 @@ queries[4]: substring = "abcda", could be changed to "abcba"
### Related Topics
+ [[Bit Manipulation](../../tag/bit-manipulation/README.md)]
[[Hash Table](../../tag/hash-table/README.md)]
[[String](../../tag/string/README.md)]
- [[Bit Manipulation](../../tag/bit-manipulation/README.md)]
[[Prefix Sum](../../tag/prefix-sum/README.md)]
-### Similar Questions
- 1. [Plates Between Candles](../plates-between-candles) (Medium)
-
### Hints
Hint 1
diff --git a/problems/capacity-to-ship-packages-within-d-days/README.md b/problems/capacity-to-ship-packages-within-d-days/README.md
index b2df14c7d..7bb5aba1c 100644
--- a/problems/capacity-to-ship-packages-within-d-days/README.md
+++ b/problems/capacity-to-ship-packages-within-d-days/README.md
@@ -65,15 +65,9 @@ Note that the cargo must be shipped in the order given, so using a ship of capac
### Related Topics
+ [[Greedy](../../tag/greedy/README.md)]
[[Array](../../tag/array/README.md)]
[[Binary Search](../../tag/binary-search/README.md)]
- [[Greedy](../../tag/greedy/README.md)]
-
-### Similar Questions
- 1. [Split Array Largest Sum](../split-array-largest-sum) (Hard)
- 1. [Divide Chocolate](../divide-chocolate) (Hard)
- 1. [Cutting Ribbons](../cutting-ribbons) (Medium)
- 1. [Minimized Maximum of Products Distributed to Any Store](../minimized-maximum-of-products-distributed-to-any-store) (Medium)
### Hints
title consisting of one or more words separated by a single space, where each word consists of English letters. Capitalize the string by changing the capitalization of each word such that:
+
+
+1 or 2 letters, change all letters to lowercase.title.
+Input: title = "capiTalIze tHe titLe"
+Output: "Capitalize The Title"
+Explanation:
+Since all the words have a length of at least 3, the first letter of each word is uppercase, and the remaining letters are lowercase.
+
+
+
+Input: title = "First leTTeR of EACH Word"
+Output: "First Letter of Each Word"
+Explanation:
+The word "of" has length 2, so it is all lowercase.
+The remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.
+
+
+
+Input: title = "i lOve leetcode"
+Output: "i Love Leetcode"
+Explanation:
+The word "i" has length 1, so it is lowercase.
+The remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.
+
+
+
+
+
+### Related Topics
+ [[String](../../tag/string/README.md)]
+
+### Hints
+1 <= title.length <= 100title consists of words separated by a single space without any leading or trailing spaces.Hint 1
+Firstly, try to find all the words present in the string.
+Hint 2
+On the basis of each word's lengths, simulate the process explained in Problem.
+capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).capacity and an array trips where trip[i] = [numPassengersi, fromi, toi] indicates that the ith trip has numPassengersi passengers and the locations to pick them up and drop them off are fromi and toi respectively. The locations are given as the number of kilometers due east from the car's initial location.capacity and an array trips where trips[i] = [numPassengersi, fromi, toi] indicates that the ith trip has numPassengersi passengers and the locations to pick them up and drop them off are fromi and toi respectively. The locations are given as the number of kilometers due east from the car's initial location.true if it is possible to pick up and drop off all passengers for all the given trips, or false otherwise.
-Input: trips = [[2,1,5],[3,5,7]], capacity = 3
-Output: true
-
-
-
-Input: trips = [[3,2,7],[3,7,9],[8,3,9]], capacity = 11
-Output: true
-
-

Input: grid = ["####F","#C...","M...."], catJump = 1, mouseJump = 2
Output: true
@@ -56,9 +54,7 @@

Input: grid = ["M.C...F"], catJump = 1, mouseJump = 4
Output: true
@@ -71,20 +67,6 @@
Output: false
-
-Input: grid = ["C...#","...#F","....#","M...."], catJump = 2, mouseJump = 5
-Output: false
-
-
-
-Input: grid = [".M...","..#..","#..#.","C#.#.","...#F"], catJump = 3, mouseJump = 1
-Output: true
-
-
Hint 1
diff --git a/problems/cheapest-flights-within-k-stops/README.md b/problems/cheapest-flights-within-k-stops/README.md
index b2cd7e7b3..04469ee9c 100644
--- a/problems/cheapest-flights-within-k-stops/README.md
+++ b/problems/cheapest-flights-within-k-stops/README.md
@@ -1,8 +1,8 @@
-
-
-
+
+
+
[< Previous](../k-th-smallest-prime-fraction "K-th Smallest Prime Fraction")
diff --git a/problems/check-array-formation-through-concatenation/README.md b/problems/check-array-formation-through-concatenation/README.md
index d010e77ab..21e3f6946 100644
--- a/problems/check-array-formation-through-concatenation/README.md
+++ b/problems/check-array-formation-through-concatenation/README.md
@@ -18,20 +18,13 @@
-Input: arr = [85], pieces = [[85]]
-Output: true
-
-
-
Input: arr = [15,88], pieces = [[88],[15]]
Output: true
-Explanation: Concatenate
-[15] then [88]
+Explanation: Concatenate [15] then [88]
Input: arr = [49,18,16], pieces = [[16,18,49]]
@@ -39,18 +32,12 @@
Explanation: Even though the numbers match, we cannot reorder pieces[0].
-
Input: arr = [91,4,64,78], pieces = [[78],[4,64],[91]]
Output: true
-Explanation: Concatenate
-
-[91] then [4,64] then [78]
-Input: arr = [1,3,5,7], pieces = [[2,4,6,8]]
-Output: false
+Explanation: Concatenate [91] then [4,64] then [78]
sum(pieces[i].length) == arr.length1 <= pieces[i].length <= arr.length1 <= arr[i], pieces[i][j] <= 100arr are distinct.pieces are distinct (i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).arr are distinct.pieces are distinct (i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).'(' and ')'. It is valid if any of the following conditions is true:
+
+
+().AB (A concatenated with B), where A and B are valid parentheses strings.(A), where A is a valid parentheses string.s and a string locked, both of length n. locked is a binary string consisting only of '0's and '1's. For each index i of locked,
+
+
+locked[i] is '1', you cannot change s[i].locked[i] is '0', you can change s[i] to either '(' or ')'.true if you can make s a valid parentheses string. Otherwise, return false.
+
+Input: s = "))()))", locked = "010100"
+Output: true
+Explanation: locked[1] == '1' and locked[3] == '1', so we cannot change s[1] or s[3].
+We change s[0] and s[4] to '(' while leaving s[2] and s[5] unchanged to make s valid.
+
+
+Input: s = "()()", locked = "0000"
+Output: true
+Explanation: We do not need to make any changes because s is already valid.
+
+
+
+Input: s = ")", locked = "0"
+Output: false
+Explanation: locked permits us to change s[0].
+Changing s[0] to either '(' or ')' will not make s valid.
+
+
+
+
+
+### Related Topics
+ [[Stack](../../tag/stack/README.md)]
+ [[Greedy](../../tag/greedy/README.md)]
+ [[String](../../tag/string/README.md)]
+
+### Hints
+n == s.length == locked.length1 <= n <= 105s[i] is either '(' or ')'.locked[i] is either '0' or '1'.Hint 1
+Can an odd length string ever be valid?
+Hint 2
+From left to right, if a locked ')' is encountered, it must be balanced with either a locked '(' or an unlocked index on its left. If neither exist, what conclusion can be drawn? If both exist, which one is more preferable to use?
+Hint 3
+After the above, we may have locked indices of '(' and additional unlocked indices. How can you balance out the locked '(' now? What if you cannot balance any locked '('?
+s and an integer k.true if every binary code of length k is a substring of s. Otherwise, return false.s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.
Input: s = "00110110", k = 2
Output: true
-Explanation: The binary codes of length 2 are "00", "01", "10" and "11". They can be all found as substrings at indicies 0, 1, 3 and 2 respectively.
+Explanation: The binary codes of length 2 are "00", "01", "10" and "11". They can be all found as substrings at indices 0, 1, 3 and 2 respectively.
-Input: s = "00110", k = 2
-Output: true
-
-
-
Input: s = "0110", k = 1
Output: true
Explanation: The binary codes of length 1 are "0" and "1", it is clear that both exist as a substring.
-
Input: s = "0110", k = 2
Output: false
-Explanation: The binary code "00" is of length 2 and doesn't exist in the array.
-
-
-
-Input: s = "0000000001011100", k = 4
-Output: false
+Explanation: The binary code "00" is of length 2 and does not exist in the array.
-Input: sentence = "i use triple pillow", searchWord = "pill"
-Output: 4
-
-
-
-Input: sentence = "hello from the other side", searchWord = "they"
-Output: -1
-
-
s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string. Otherwise, return false.
+Input: s = "aaabbb"
+Output: true
+Explanation:
+The 'a's are at indices 0, 1, and 2, while the 'b's are at indices 3, 4, and 5.
+Hence, every 'a' appears before every 'b' and we return true.
+
+
+
+Input: s = "abab"
+Output: false
+Explanation:
+There is an 'a' at index 2 and a 'b' at index 1.
+Hence, not every 'a' appears before every 'b' and we return false.
+
+
+
+Input: s = "bbb"
+Output: true
+Explanation:
+There are no 'a's, hence, every 'a' appears before every 'b' and we return true.
+
+
+
+
+
+### Related Topics
+ [[String](../../tag/string/README.md)]
+
+### Hints
+1 <= s.length <= 100s[i] is either 'a' or 'b'.Hint 1
+You can check the opposite: check if there is a ‘b’ before an ‘a’. Then, negate and return that answer.
+Hint 2
+s should not have any occurrences of “ba” as a substring.
+Hint 1
diff --git a/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md b/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md
index ce29c124c..caeebf97b 100644
--- a/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md
+++ b/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md
@@ -74,32 +74,6 @@
- The original string encoded as s2 must start with the letter 'c'.
-
-Input: s1 = "112s", s2 = "g841"
-Output: true
-Explanation: It is possible that "gaaaaaaaaaaaas" was the original string
-- "gaaaaaaaaaaaas"
- -> Split: ["g", "aaaaaaaaaaaa", "s"]
- -> Replace: ["1", "12", "s"]
- -> Concatenate: "112s", which is s1.
-- "gaaaaaaaaaaaas"
- -> Split: ["g", "aaaaaaaa", "aaaa", "s"]
- -> Replace: ["g", "8", "4", "1"]
- -> Concatenate: "g841", which is s2.
-
-
-
-Input: s1 = "ab", s2 = "a2"
-Output: false
-Explanation: It is impossible.
-- The original string encoded as s1 has two letters.
-- The original string encoded as s2 has three letters.
-
-
-Input: nums = [1,1,1]
-Output: true
-Explanation: [1,1,1] is the original sorted array.
-You can rotate any number of positions to make nums.
-
-
-
-Input: nums = [2,1]
-Output: true
-Explanation: [1,2] is the original sorted array.
-You can rotate the array by x = 5 positions to begin on the element of value 2: [2,1].
-
-
arr of even length n and an integer k.n / 2 pairs such that the sum of each pair is divisible by k.n / 2 pairs such that the sum of each pair is divisible by k.true If you can find a way to do that or false otherwise.
-Input: arr = [-10,10], k = 2
-Output: true
-
-
-
-Input: arr = [-1,1,-2,2,-3,3,-4,4], k = 3
-Output: true
-
-
Hint 1
diff --git a/problems/check-if-every-row-and-column-contains-all-numbers/README.md b/problems/check-if-every-row-and-column-contains-all-numbers/README.md
new file mode 100644
index 000000000..b3597801f
--- /dev/null
+++ b/problems/check-if-every-row-and-column-contains-all-numbers/README.md
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+[< Previous](../stamping-the-grid "Stamping the Grid")
+
+[Next >](../minimum-swaps-to-group-all-1s-together-ii "Minimum Swaps to Group All 1's Together II")
+
+## [2133. Check if Every Row and Column Contains All Numbers (Easy)](https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers "检查是否每一行每一列都包含全部整数")
+
+n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive).n x n integer matrix matrix, return true if the matrix is valid. Otherwise, return false.
+
+Input: matrix = [[1,2,3],[3,1,2],[2,3,1]]
+Output: true
+Explanation: In this case, n = 3, and every row and column contains the numbers 1, 2, and 3.
+Hence, we return true.
+
+
+
+
+Input: matrix = [[1,1,1],[1,2,3],[1,2,3]]
+Output: false
+Explanation: In this case, n = 3, but the first row and the first column do not contain the numbers 2 or 3.
+Hence, we return false.
+
+
+
+
+
+### Related Topics
+ [[Array](../../tag/array/README.md)]
+ [[Hash Table](../../tag/hash-table/README.md)]
+ [[Matrix](../../tag/matrix/README.md)]
+
+### Hints
+n == matrix.length == matrix[i].length1 <= n <= 1001 <= matrix[i][j] <= nHint 1
+Use for loops to check each row for every number from 1 to n. Similarly, do the same for each column.
+Hint 2
+For each check, you can keep a set of the unique elements in the checked row/col. By the end of the check, the size of the set should be n.
+Hint 1
diff --git a/problems/check-if-numbers-are-ascending-in-a-sentence/README.md b/problems/check-if-numbers-are-ascending-in-a-sentence/README.md
index 7c77fe501..f23398623 100644
--- a/problems/check-if-numbers-are-ascending-in-a-sentence/README.md
+++ b/problems/check-if-numbers-are-ascending-in-a-sentence/README.md
@@ -47,15 +47,6 @@ They are strictly increasing from left to right: 1 < 3 < 4 < 6 < 12.
Explanation: The numbers in s are: 7, 51, 50, 60. They are not strictly increasing.
-
-Input: s = "4 5 11 26"
-Output: true
-Explanation: The numbers in s are: 4, 5, 11, 26.
-They are strictly increasing from left to right: 4 < 5 < 11 < 26.
-
-
-Input: s1 = "abcd", s2 = "dcba"
-Output: false
-
-
Hint 1
diff --git a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md
index 439964b1e..59a65dbb5 100644
--- a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md
+++ b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md
@@ -11,17 +11,19 @@
## [1585. Check If String Is Transformable With Substring Sort Operations (Hard)](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串")
-s and t, you want to transform string s into string t using the following operation any number of times:s and t, transform string s into string t using the following operation any number of times:
-
-s and sort it in-place so the characters are in ascending order.s and sort it in place so the characters are in ascending order.
+
+
+ "14234" results in "12344"."14234" results in "12344".true if it is possible to transform s into t. Otherwise, return false.true if it is possible to transform string s into string t. Otherwise, return false.
-Input: s = "1", t = "2"
-Output: false
-
-
### Related Topics
diff --git a/problems/checking-existence-of-edge-length-limited-paths/README.md b/problems/checking-existence-of-edge-length-limited-paths/README.md
index 86f617a92..cb9115df3 100644
--- a/problems/checking-existence-of-edge-length-limited-paths/README.md
+++ b/problems/checking-existence-of-edge-length-limited-paths/README.md
@@ -52,14 +52,11 @@ For the second query, there is a path (0 -> 1 -> 2) of two edges with dist
### Related Topics
- [[Array](../../tag/array/README.md)]
[[Union Find](../../tag/union-find/README.md)]
[[Graph](../../tag/graph/README.md)]
+ [[Array](../../tag/array/README.md)]
[[Sorting](../../tag/sorting/README.md)]
-### Similar Questions
- 1. [Checking Existence of Edge Length Limited Paths II](../checking-existence-of-edge-length-limited-paths-ii) (Hard)
-
### Hints
s.length == t.length1 <= s.length <= 105s and t only contain digits from '0' to '9'.s and t consist of only digits.Hint 1
diff --git a/problems/cherry-pickup-ii/README.md b/problems/cherry-pickup-ii/README.md
index 0dac251a8..e44b8c7f0 100644
--- a/problems/cherry-pickup-ii/README.md
+++ b/problems/cherry-pickup-ii/README.md
@@ -11,61 +11,48 @@
## [1463. Cherry Pickup II (Hard)](https://leetcode.com/problems/cherry-pickup-ii "摘樱桃 II")
-rows x cols matrix grid representing a field of cherries. Each cell in grid represents the number of cherries that you can collect.rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell.
+
+
+(0, 0), and(0, cols - 1).
-
grid.(i, j), robots can move to cell (i + 1, j - 1), (i + 1, j), or (i + 1, j + 1).grid.
Input: grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]
Output: 24
-Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
+Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
Cherries taken by Robot #1, (3 + 2 + 5 + 2) = 12.
Cherries taken by Robot #2, (1 + 5 + 5 + 1) = 12.
Total of cherries: 12 + 12 = 24.

Input: grid = [[1,0,0,0,0,0,1],[2,0,0,0,0,3,0],[2,0,9,0,0,0,0],[0,3,0,5,4,0,0],[1,0,2,3,0,0,6]]
Output: 28
-Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
+Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
Cherries taken by Robot #1, (1 + 9 + 5 + 2) = 17.
Cherries taken by Robot #2, (1 + 3 + 4 + 3) = 11.
Total of cherries: 17 + 11 = 28.
-
-Input: grid = [[1,0,0,3],[0,0,0,3],[0,0,3,3],[9,0,3,3]]
-Output: 22
-
-
-
-Input: grid = [[1,1],[1,1]]
-Output: 4
-
-
rows == grid.lengthcols == grid[i].length2 <= rows, cols <= 700 <= grid[i][j] <= 100 0 <= grid[i][j] <= 100Hint 1
+If you know the possible sums you can get for a range [l, r], how can you use this information to calculate the possible sums you can get for a range [l, r + 1]?
+Hint 2
+For the range [l, r], if it is possible to choose elements such that the sum of elements you picked from nums1 is x and the sum of elements you picked from nums2 is y, then (x + nums1[r + 1], y) and (x, y + nums2[r + 1]) are possible sums you can get in the range [l, r + 1].
+Hint 3
+How can we save the possible sums obtainable at a given index so that we can reuse this information later?
+radius, x_center, y_center) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.(radius, xCenter, yCenter) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.true if the circle and rectangle are overlapped otherwise return false. In other words, check if there is any point (xi, yi) that belongs to the circle and the rectangle at the same time.
-Input: radius = 1, x_center = 0, y_center = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
+Input: radius = 1, xCenter = 0, yCenter = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
Output: true
-Explanation: Circle and rectangle share the point (1,0)
+Explanation: Circle and rectangle share the point (1,0).

-Input: radius = 1, x_center = 0, y_center = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
-Output: true
+Input: radius = 1, xCenter = 1, yCenter = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1
+Output: false

-Input: radius = 1, x_center = 1, y_center = 1, x1 = -3, y1 = -3, x2 = 3, y2 = 3
+Input: radius = 1, xCenter = 0, yCenter = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
Output: true
-
-Input: radius = 1, x_center = 1, y_center = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1
-Output: false
-
-
### Related Topics
- [[Geometry](../../tag/geometry/README.md)]
[[Math](../../tag/math/README.md)]
+ [[Geometry](../../tag/geometry/README.md)]
### Hints
1 <= radius <= 2000-10^4 <= x_center, y_center, x1, y1, x2, y2 <= 10^4x1 < x2y1 < y2-104 <= xCenter, yCenter <= 104-104 <= x1 < x2 <= 104-104 <= y1 < y2 <= 104
-Input: baseCosts = [10], toppingCosts = [1], target = 1
-Output: 10
-Explanation: Notice that you don't have to have any toppings, but you must have exactly one base.
-
-Input: candidates = [1], target = 1
-Output: [[1]]
-
-
-
-Input: candidates = [1], target = 2
-Output: [[1,1]]
-
-
-Input: s = "triplepillooooow"
-Output: 5
-
-
-
-Input: s = "hooraaaaaaaaaaay"
-Output: 11
-
-
-
-Input: s = "tourist"
-Output: 1
-
-
Hint 1
diff --git a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md
index 5271b0d6f..f48710384 100644
--- a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md
+++ b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md
@@ -1,8 +1,8 @@
-
-
-
+
+
+
[< Previous](../construct-binary-tree-from-preorder-and-inorder-traversal "Construct Binary Tree from Preorder and Inorder Traversal")
@@ -42,10 +42,10 @@
### Related Topics
- [[Tree](../../tag/tree/README.md)]
[[Array](../../tag/array/README.md)]
[[Hash Table](../../tag/hash-table/README.md)]
[[Divide and Conquer](../../tag/divide-and-conquer/README.md)]
+ [[Tree](../../tag/tree/README.md)]
[[Binary Tree](../../tag/binary-tree/README.md)]
### Similar Questions
diff --git a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md
index 37ae76162..eb1be2100 100644
--- a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md
+++ b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md
@@ -1,8 +1,8 @@
-
-
-
+
+
+
[< Previous](../fair-candy-swap "Fair Candy Swap")
diff --git a/problems/construct-binary-tree-from-string/README.md b/problems/construct-binary-tree-from-string/README.md
index 05bb73e4e..985211a95 100644
--- a/problems/construct-binary-tree-from-string/README.md
+++ b/problems/construct-binary-tree-from-string/README.md
@@ -1,8 +1,8 @@
-
-
-
+
+
+
[< Previous](../encode-and-decode-tinyurl "Encode and Decode TinyURL")
@@ -38,9 +38,9 @@
Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.
You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).
Find two lines that together with the x-axis form a container, such that the container contains the most water.
+ +Return the maximum amount of water a container can store.
Notice that you may not slant the container.
@@ -21,7 +25,7 @@Input: height = [1,8,6,2,5,4,8,3,7] Output: 49 -Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49. +Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.
Example 2:
@@ -31,20 +35,6 @@ Output: 1 -Example 3:
- --Input: height = [4,3,2,1,4] -Output: 16 -- -
Example 4:
- --Input: height = [1,2,1] -Output: 2 --
Constraints:
diff --git a/problems/contiguous-array/README.md b/problems/contiguous-array/README.md index b0b4dbc33..39dec4a3a 100644 --- a/problems/contiguous-array/README.md +++ b/problems/contiguous-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-word-in-dictionary-through-deleting "Longest Word in Dictionary through Deleting") diff --git a/problems/continuous-subarray-sum/README.md b/problems/continuous-subarray-sum/README.md index b70633b7c..f182bd82e 100644 --- a/problems/continuous-subarray-sum/README.md +++ b/problems/continuous-subarray-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-uncommon-subsequence-ii "Longest Uncommon Subsequence II") diff --git a/problems/convert-1d-array-into-2d-array/README.md b/problems/convert-1d-array-into-2d-array/README.md index 43070be5f..1a2c6e69f 100644 --- a/problems/convert-1d-array-into-2d-array/README.md +++ b/problems/convert-1d-array-into-2d-array/README.md @@ -23,8 +23,7 @@Input: original = [1,2,3,4], m = 2, n = 2 Output: [[1,2],[3,4]] -Explanation: -The constructed 2D array should contain 2 rows and 2 columns. +Explanation: The constructed 2D array should contain 2 rows and 2 columns. The first group of n=2 elements in original, [1,2], becomes the first row in the constructed 2D array. The second group of n=2 elements in original, [3,4], becomes the second row in the constructed 2D array.@@ -34,8 +33,7 @@ The second group of n=2 elements in original, [3,4], becomes the second row in t
Input: original = [1,2,3], m = 1, n = 3 Output: [[1,2,3]] -Explanation: -The constructed 2D array should contain 1 row and 3 columns. +Explanation: The constructed 2D array should contain 1 row and 3 columns. Put all three elements in original into the first row of the constructed 2D array.@@ -44,21 +42,10 @@ Put all three elements in original into the first row of the constructed 2D arra
Input: original = [1,2], m = 1, n = 1 Output: [] -Explanation: -There are 2 elements in original. +Explanation: There are 2 elements in original. It is impossible to fit 2 elements in a 1x1 2D array, so return an empty 2D array.-
Example 4:
- --Input: original = [3], m = 1, n = 2 -Output: [] -Explanation: -There is 1 element in original. -It is impossible to make 1 element fill all the spots in a 1x2 2D array, so return an empty 2D array. --
Constraints:
diff --git a/problems/convert-bst-to-greater-tree/README.md b/problems/convert-bst-to-greater-tree/README.md index 203b61449..d29540249 100644 --- a/problems/convert-bst-to-greater-tree/README.md +++ b/problems/convert-bst-to-greater-tree/README.md @@ -23,7 +23,7 @@
Example 1:
-
+
Input: root = [4,1,6,0,2,5,7,null,null,null,3,null,null,null,8] Output: [30,36,21,36,35,26,15,null,null,null,33,null,null,null,8] @@ -36,20 +36,6 @@ Output: [1,null,1]-
Example 3:
- --Input: root = [1,0,2] -Output: [3,3,2] -- -
Example 4:
- --Input: root = [3,2,4,1] -Output: [7,9,4,10] --
Constraints:
diff --git a/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md b/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md index 7f0be835b..c06050fea 100644 --- a/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md +++ b/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md @@ -11,16 +11,16 @@ ## [1317. Convert Integer to the Sum of Two No-Zero Integers (Easy)](https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers "将整数转换为两个无零整数的和") -Given an integer n. No-Zero integer is a positive integer which doesn't contain any 0 in its decimal representation.
No-Zero integer is a positive integer that does not contain any 0 in its decimal representation.
Return a list of two integers [A, B] where:
Given an integer n, return a list of two integers [A, B] where:
A and B are No-Zero integers.A and B are No-Zero integers.A + B = nIt's guarateed that there is at least one valid solution. If there are many valid solutions you can return any of them.
+The test cases are generated so that there is at least one valid solution. If there are many valid solutions you can return any of them.
Example 1:
@@ -28,7 +28,7 @@Input: n = 2 Output: [1,1] -Explanation: A = 1, B = 1. A + B = n and both A and B don't contain any 0 in their decimal representation. +Explanation: A = 1, B = 1. A + B = n and both A and B do not contain any 0 in their decimal representation.
Example 2:
@@ -38,32 +38,11 @@ Output: [2,9] -Example 3:
- --Input: n = 10000 -Output: [1,9999] -- -
Example 4:
- --Input: n = 69 -Output: [1,68] -- -
Example 5:
- --Input: n = 1010 -Output: [11,999] --
Constraints:
2 <= n <= 10^42 <= n <= 104
Example 1:
-
+
Input: head = [-10,-3,0,5,9] Output: [0,-3,9,-10,null,5] @@ -31,20 +31,6 @@ Output: []-
Example 3:
- --Input: head = [0] -Output: [0] -- -
Example 4:
- --Input: head = [1,3] -Output: [3,1] --
Constraints:
diff --git a/problems/coordinate-with-maximum-network-quality/README.md b/problems/coordinate-with-maximum-network-quality/README.md index 91f1ce025..6ada4d259 100644 --- a/problems/coordinate-with-maximum-network-quality/README.md +++ b/problems/coordinate-with-maximum-network-quality/README.md @@ -59,23 +59,6 @@ No other coordinate has a higher network quality. Explanation: Coordinate (1, 2) has the highest network quality. -Example 4:
- --Input: towers = [[2,1,9],[0,1,9]], radius = 2 -Output: [0,1] -Explanation: Both (0, 1) and (2, 1) are optimal in terms of quality, but (0, 1) is lexicographically minimal. -- -
Example 5:
- --Input: towers = [[42,0,0]], radius = 7 -Output: [0,0] -Explanation: The network quality is 0 at every coordinate, even at the tower's location. -Thus, the lexicographically minimum non-negative coordinate is (0, 0). --
Constraints:
diff --git a/problems/corporate-flight-bookings/README.md b/problems/corporate-flight-bookings/README.md index e48e88b45..63e874b4c 100644 --- a/problems/corporate-flight-bookings/README.md +++ b/problems/corporate-flight-bookings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../defanging-an-ip-address "Defanging an IP Address") diff --git a/problems/count-all-possible-routes/README.md b/problems/count-all-possible-routes/README.md index 9dfddc3fe..5de9e8ec3 100644 --- a/problems/count-all-possible-routes/README.md +++ b/problems/count-all-possible-routes/README.md @@ -25,7 +25,7 @@Input: locations = [2,3,6,8,4], start = 1, finish = 3, fuel = 5 Output: 4 -Explanation: The following are all possible routes, each uses 5 units of fuel: +Explanation: The following are all possible routes, each uses 5 units of fuel: 1 -> 3 1 -> 2 -> 3 1 -> 4 -> 3 @@ -37,7 +37,7 @@-Input: locations = [4,3,1], start = 1, finish = 0, fuel = 6 Output: 5 -Explanation: The following are all possible routes: +Explanation: The following are all possible routes: 1 -> 0, used fuel = 1 1 -> 2 -> 0, used fuel = 5 1 -> 2 -> 1 -> 0, used fuel = 5 @@ -50,21 +50,7 @@Input: locations = [5,2,1], start = 0, finish = 2, fuel = 3 Output: 0 -Explanation: It's impossible to get from 0 to 2 using only 3 units of fuel since the shortest route needs 4 units of fuel.- -Example 4:
- --Input: locations = [2,1,5], start = 0, finish = 0, fuel = 3 -Output: 2 -Explanation: There are two possible routes, 0 and 0 -> 1 -> 0.- -Example 5:
- --Input: locations = [1,2,3], start = 0, finish = 2, fuel = 40 -Output: 615088286 -Explanation: The total number of possible routes is 2615088300. Taking this number modulo 10^9 + 7 gives us 615088286. +Explanation: It is impossible to get from 0 to 2 using only 3 units of fuel since the shortest route needs 4 units of fuel.@@ -79,9 +65,9 @@ ### Related Topics - [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Memoization](../../tag/memoization/README.md)] ### Hints
diff --git a/problems/count-all-valid-pickup-and-delivery-options/README.md b/problems/count-all-valid-pickup-and-delivery-options/README.md index 2ff24eb41..32cda0c3e 100644 --- a/problems/count-all-valid-pickup-and-delivery-options/README.md +++ b/problems/count-all-valid-pickup-and-delivery-options/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-substrings-containing-all-three-characters "Number of Substrings Containing All Three Characters") diff --git a/problems/count-binary-substrings/README.md b/problems/count-binary-substrings/README.md index 42e1f4151..de93a8d21 100644 --- a/problems/count-binary-substrings/README.md +++ b/problems/count-binary-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-area-of-island "Max Area of Island") diff --git a/problems/count-common-words-with-one-occurrence/README.md b/problems/count-common-words-with-one-occurrence/README.md new file mode 100644 index 000000000..776b6f8bc --- /dev/null +++ b/problems/count-common-words-with-one-occurrence/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../drop-type-1-orders-for-customers-with-type-0-orders "Drop Type 1 Orders for Customers With Type 0 Orders") + +[Next >](../minimum-number-of-buckets-required-to-collect-rainwater-from-houses "Minimum Number of Buckets Required to Collect Rainwater from Houses") + +## [2085. Count Common Words With One Occurrence (Easy)](https://leetcode.com/problems/count-common-words-with-one-occurrence "统计出现过一次的公共字符串") + +Given two string arrays
+ +words1andwords2, return the number of strings that appear exactly once in each of the two arrays.+
Example 1:
+ ++Input: words1 = ["leetcode","is","amazing","as","is"], words2 = ["amazing","leetcode","is"] +Output: 2 +Explanation: +- "leetcode" appears exactly once in each of the two arrays. We count this string. +- "amazing" appears exactly once in each of the two arrays. We count this string. +- "is" appears in each of the two arrays, but there are 2 occurrences of it in words1. We do not count this string. +- "as" appears once in words1, but does not appear in words2. We do not count this string. +Thus, there are 2 strings that appear exactly once in each of the two arrays. ++ +Example 2:
+ ++Input: words1 = ["b","bb","bbb"], words2 = ["a","aa","aaa"] +Output: 0 +Explanation: There are no strings that appear in each of the two arrays. ++ +Example 3:
+ ++Input: words1 = ["a","ab"], words2 = ["a","a","a","ab"] +Output: 1 +Explanation: The only string that appears exactly once in each of the two arrays is "ab". ++ ++
Constraints:
+ ++
+ +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +- +
1 <= words1.length, words2.length <= 1000- +
1 <= words1[i].length, words2[j].length <= 30- +
words1[i]andwords2[j]consists only of lowercase English letters.++ +Hint 1
+Could you try every word? ++diff --git a/problems/count-different-palindromic-subsequences/README.md b/problems/count-different-palindromic-subsequences/README.md index ffc4a31e6..c0d8334f8 100644 --- a/problems/count-different-palindromic-subsequences/README.md +++ b/problems/count-different-palindromic-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../my-calendar-i "My Calendar I") diff --git a/problems/count-elements-with-strictly-smaller-and-greater-elements/README.md b/problems/count-elements-with-strictly-smaller-and-greater-elements/README.md new file mode 100644 index 000000000..199267f0b --- /dev/null +++ b/problems/count-elements-with-strictly-smaller-and-greater-elements/README.md @@ -0,0 +1,62 @@ + + + + + + + +[< Previous](../number-of-ways-to-divide-a-long-corridor "Number of Ways to Divide a Long Corridor") + +[Next >](../rearrange-array-elements-by-sign "Rearrange Array Elements by Sign") + +## [2148. Count Elements With Strictly Smaller and Greater Elements (Easy)](https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements "元素计数") + +Hint 2
+Could you use a hash map to achieve a good complexity? +Given an integer array
+ +nums, return the number of elements that have both a strictly smaller and a strictly greater element appear innums.+
Example 1:
+ ++Input: nums = [11,7,2,15] +Output: 2 +Explanation: The element 7 has the element 2 strictly smaller than it and the element 11 strictly greater than it. +Element 11 has element 7 strictly smaller than it and element 15 strictly greater than it. +In total there are 2 elements having both a strictly smaller and a strictly greater element appear in+ +nums. +Example 2:
+ ++Input: nums = [-3,3,3,90] +Output: 2 +Explanation: The element 3 has the element -3 strictly smaller than it and the element 90 strictly greater than it. +Since there are two elements with the value 3, in total there are 2 elements having both a strictly smaller and a strictly greater element appear in+ +nums. ++
Constraints:
+ ++
+ +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +- +
1 <= nums.length <= 100- +
-105 <= nums[i] <= 105++ +Hint 1
+All the elements in the array should be counted except for the minimum and maximum elements. +++ +Hint 2
+If the array has n elements, the answer will be n - count(min(nums)) - count(max(nums)) ++diff --git a/problems/count-fertile-pyramids-in-a-land/README.md b/problems/count-fertile-pyramids-in-a-land/README.md new file mode 100644 index 000000000..9e438e6a1 --- /dev/null +++ b/problems/count-fertile-pyramids-in-a-land/README.md @@ -0,0 +1,99 @@ + + + + + + + +[< Previous](../minimum-cost-homecoming-of-a-robot-in-a-grid "Minimum Cost Homecoming of a Robot in a Grid") + +[Next >](../find-target-indices-after-sorting-array "Find Target Indices After Sorting Array") + +## [2088. Count Fertile Pyramids in a Land (Hard)](https://leetcode.com/problems/count-fertile-pyramids-in-a-land "统计农场中肥沃金字塔的数目") + +Hint 3
+This formula will not work in case the array has all the elements equal, why? +A farmer has a rectangular grid of land with
+ +mrows andncolumns that can be divided into unit cells. Each cell is either fertile (represented by a1) or barren (represented by a0). All cells outside the grid are considered barren.A pyramidal plot of land can be defined as a set of cells with the following criteria:
+ ++
+ +- The number of cells in the set has to be greater than
+1and all cells must be fertile.- The apex of a pyramid is the topmost cell of the pyramid. The height of a pyramid is the number of rows it covers. Let
+(r, c)be the apex of the pyramid, and its height beh. Then, the plot comprises of cells(i, j)wherer <= i <= r + h - 1andc - (i - r) <= j <= c + (i - r).An inverse pyramidal plot of land can be defined as a set of cells with similar criteria:
+ ++
+ +- The number of cells in the set has to be greater than
+1and all cells must be fertile.- The apex of an inverse pyramid is the bottommost cell of the inverse pyramid. The height of an inverse pyramid is the number of rows it covers. Let
+(r, c)be the apex of the pyramid, and its height beh. Then, the plot comprises of cells(i, j)wherer - h + 1 <= i <= randc - (r - i) <= j <= c + (r - i).Some examples of valid and invalid pyramidal (and inverse pyramidal) plots are shown below. Black cells indicate fertile cells.
++
Given a 0-indexed
+ +m x nbinary matrixgridrepresenting the farmland, return the total number of pyramidal and inverse pyramidal plots that can be found ingrid.+
Example 1:
++
+Input: grid = [[0,1,1,0],[1,1,1,1]] +Output: 2 +Explanation: The 2 possible pyramidal plots are shown in blue and red respectively. +There are no inverse pyramidal plots in this grid. +Hence total number of pyramidal and inverse pyramidal plots is 2 + 0 = 2. ++ +Example 2:
++
+Input: grid = [[1,1,1],[1,1,1]] +Output: 2 +Explanation: The pyramidal plot is shown in blue, and the inverse pyramidal plot is shown in red. +Hence the total number of plots is 1 + 1 = 2. ++ +Example 3:
++
+Input: grid = [[1,1,1,1,0],[1,1,1,1,1],[1,1,1,1,1],[0,1,0,0,1]] +Output: 13 +Explanation: There are 7 pyramidal plots, 3 of which are shown in the 2nd and 3rd figures. +There are 6 inverse pyramidal plots, 2 of which are shown in the last figure. +The total number of plots is 7 + 6 = 13. ++ ++
Constraints:
+ ++
+ +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +- +
m == grid.length- +
n == grid[i].length- +
1 <= m, n <= 1000- +
1 <= m * n <= 105- +
grid[i][j]is either0or1.++ +Hint 1
+Think about how dynamic programming can help solve the problem. +++ +Hint 2
+For any fixed cell (r, c), can you calculate the maximum height of the pyramid for which it is the apex? Let us denote this value as dp[r][c]. +++ +Hint 3
+How will the values at dp[r+1][c-1] and dp[r+1][c+1] help in determining the value at dp[r][c]? ++diff --git a/problems/count-good-meals/README.md b/problems/count-good-meals/README.md index a79cf7106..472223138 100644 --- a/problems/count-good-meals/README.md +++ b/problems/count-good-meals/README.md @@ -48,6 +48,11 @@ Their respective sums are 4, 8, 8, and 16, all of which are powers of 2. [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] +### Similar Questions + 1. [Two Sum](../two-sum) (Easy) + 1. [Max Number of K-Sum Pairs](../max-number-of-k-sum-pairs) (Medium) + 1. [Find All Possible Recipes from Given Supplies](../find-all-possible-recipes-from-given-supplies) (Medium) + ### HintsHint 4
+For the cell (r, c), is there a relation between the number of pyramids for which it serves as the apex and dp[r][c]? How does it help in calculating the answer? +Hint 1
diff --git a/problems/count-good-nodes-in-binary-tree/README.md b/problems/count-good-nodes-in-binary-tree/README.md index acab1defb..4a8baa459 100644 --- a/problems/count-good-nodes-in-binary-tree/README.md +++ b/problems/count-good-nodes-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../simplified-fractions "Simplified Fractions") diff --git a/problems/count-good-triplets/README.md b/problems/count-good-triplets/README.md index 782b76d51..10a302420 100644 --- a/problems/count-good-triplets/README.md +++ b/problems/count-good-triplets/README.md @@ -56,9 +56,6 @@ [[Array](../../tag/array/README.md)] [[Enumeration](../../tag/enumeration/README.md)] -### Similar Questions - 1. [Count Special Quadruplets](../count-special-quadruplets) (Easy) - ### HintsHint 1
diff --git a/problems/count-largest-group/README.md b/problems/count-largest-group/README.md index 577545eae..38160b260 100644 --- a/problems/count-largest-group/README.md +++ b/problems/count-largest-group/README.md @@ -11,9 +11,11 @@ ## [1399. Count Largest Group (Easy)](https://leetcode.com/problems/count-largest-group "统计最大组的数目") -Given an integer
+n. Each number from1tonis grouped according to the sum of its digits.You are given an integer
-n.Return how many groups have the largest size.
+Each number from
+ +1tonis grouped according to the sum of its digits.Return the number of groups that have the largest size.
Example 1:
@@ -22,7 +24,8 @@ Input: n = 13 Output: 4 Explanation: There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13: -[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9]. There are 4 groups with largest size. +[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9]. +There are 4 groups with largest size.Example 2:
@@ -33,25 +36,11 @@ Explanation: There are 2 groups [1], [2] of size 1.
Example 3:
- --Input: n = 15 -Output: 6 -- -
Example 4:
- --Input: n = 24 -Output: 5 --
Constraints:
1 <= n <= 10^41 <= n <= 104Example 3:
- --Input: grid = [[1,-1],[-1,-1]] -Output: 3 -- -
Example 4:
- --Input: grid = [[-1]] -Output: 1 --
Constraints:
diff --git a/problems/count-nice-pairs-in-an-array/README.md b/problems/count-nice-pairs-in-an-array/README.md index ce79ee89e..5cc54e815 100644 --- a/problems/count-nice-pairs-in-an-array/README.md +++ b/problems/count-nice-pairs-in-an-array/README.md @@ -52,6 +52,9 @@ [[Math](../../tag/math/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Number of Pairs of Interchangeable Rectangles](../number-of-pairs-of-interchangeable-rectangles) (Medium) + ### HintsYou are given two non-negative integers num1 and num2.
In one operation, if num1 >= num2, you must subtract num2 from num1, otherwise subtract num1 from num2.
num1 = 5 and num2 = 4, subtract num2 from num1, thus obtaining num1 = 1 and num2 = 4. However, if num1 = 4 and num2 = 5, after one operation, num1 = 4 and num2 = 1.Return the number of operations required to make either num1 = 0 or num2 = 0.
+
Example 1:
+ ++Input: num1 = 2, num2 = 3 +Output: 3 +Explanation: +- Operation 1: num1 = 2, num2 = 3. Since num1 < num2, we subtract num1 from num2 and get num1 = 2, num2 = 3 - 2 = 1. +- Operation 2: num1 = 2, num2 = 1. Since num1 > num2, we subtract num2 from num1. +- Operation 3: num1 = 1, num2 = 1. Since num1 == num2, we subtract num2 from num1. +Now num1 = 0 and num2 = 1. Since num1 == 0, we do not need to perform any further operations. +So the total number of operations required is 3. ++ +
Example 2:
+ ++Input: num1 = 10, num2 = 10 +Output: 1 +Explanation: +- Operation 1: num1 = 10, num2 = 10. Since num1 == num2, we subtract num2 from num1 and get num1 = 10 - 10 = 0. +Now num1 = 0 and num2 = 10. Since num1 == 0, we are done. +So the total number of operations required is 1. ++ +
+
Constraints:
+ +0 <= num1, num2 <= 105
Input: s = "aba", t = "baba"
Output: 6
-Explanation: The following are the pairs of substrings from s and t that differ by exactly 1 character:
+Explanation: The following are the pairs of substrings from s and t that differ by exactly 1 character:
("aba", "baba")
("aba", "baba")
("aba", "baba")
@@ -39,25 +39,12 @@ The underlined portions are the substrings that are chosen from s and t.
Input: s = "ab", t = "bb"
Output: 3
-Explanation: The following are the pairs of substrings from s and t that differ by 1 character:
+Explanation: The following are the pairs of substrings from s and t that differ by 1 character:
("ab", "bb")
("ab", "bb")
("ab", "bb")
The underlined portions are the substrings that are chosen from s and t.
-Example 3:
-
-
-Input: s = "a", t = "a"
-Output: 0
-
-
-Example 4:
-
-
-Input: s = "abe", t = "bbc"
-Output: 10
-
Constraints:
@@ -72,6 +59,9 @@ The underlined portions are the substrings that are chosen from s and t.
[[String](../../tag/string/README.md)]
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
+### Similar Questions
+ 1. [Count Words Obtained After Adding a Letter](../count-words-obtained-after-adding-a-letter) (Medium)
+
### Hints
Hint 1
diff --git a/problems/count-subtrees-with-max-distance-between-cities/README.md b/problems/count-subtrees-with-max-distance-between-cities/README.md
index b2fafe331..4b8a8e661 100644
--- a/problems/count-subtrees-with-max-distance-between-cities/README.md
+++ b/problems/count-subtrees-with-max-distance-between-cities/README.md
@@ -61,14 +61,11 @@ No subtree has two nodes where the max distance between them is 3.
### Related Topics
- [[Dynamic Programming](../../tag/dynamic-programming/README.md)]
[[Bit Manipulation](../../tag/bit-manipulation/README.md)]
[[Tree](../../tag/tree/README.md)]
- [[Enumeration](../../tag/enumeration/README.md)]
+ [[Dynamic Programming](../../tag/dynamic-programming/README.md)]
[[Bitmask](../../tag/bitmask/README.md)]
-
-### Similar Questions
- 1. [Tree Diameter](../tree-diameter) (Medium)
+ [[Enumeration](../../tag/enumeration/README.md)]
### Hints
diff --git a/problems/count-the-hidden-sequences/README.md b/problems/count-the-hidden-sequences/README.md
new file mode 100644
index 000000000..7b6dd0bc0
--- /dev/null
+++ b/problems/count-the-hidden-sequences/README.md
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+[< Previous](../minimum-cost-of-buying-candies-with-discount "Minimum Cost of Buying Candies With Discount")
+
+[Next >](../k-highest-ranked-items-within-a-price-range "K Highest Ranked Items Within a Price Range")
+
+## [2145. Count the Hidden Sequences (Medium)](https://leetcode.com/problems/count-the-hidden-sequences "统计隐藏数组数目")
+
+You are given a 0-indexed array of n integers differences, which describes the differences between each pair of consecutive integers of a hidden sequence of length (n + 1). More formally, call the hidden sequence hidden, then we have that differences[i] = hidden[i + 1] - hidden[i].
+
+You are further given two integers lower and upper that describe the inclusive range of values [lower, upper] that the hidden sequence can contain.
+
+
+ - For example, given
differences = [1, -3, 4], lower = 1, upper = 6, the hidden sequence is a sequence of length 4 whose elements are in between 1 and 6 (inclusive).
+
+ [3, 4, 1, 5] and [4, 5, 2, 6] are possible hidden sequences.
+ [5, 6, 3, 7] is not possible since it contains an element greater than 6.
+ [1, 2, 3, 4] is not possible since the differences are not correct.
+
+
+
+
+Return the number of possible hidden sequences there are. If there are no possible sequences, return 0.
+
+
+Example 1:
+
+
+Input: differences = [1,-3,4], lower = 1, upper = 6
+Output: 2
+Explanation: The possible hidden sequences are:
+- [3, 4, 1, 5]
+- [4, 5, 2, 6]
+Thus, we return 2.
+
+
+Example 2:
+
+
+Input: differences = [3,-4,5,1,-2], lower = -4, upper = 5
+Output: 4
+Explanation: The possible hidden sequences are:
+- [-3, 0, -4, 1, 2, 0]
+- [-2, 1, -3, 2, 3, 1]
+- [-1, 2, -2, 3, 4, 2]
+- [0, 3, -1, 4, 5, 3]
+Thus, we return 4.
+
+
+Example 3:
+
+
+Input: differences = [4,-7,2], lower = 3, upper = 6
+Output: 0
+Explanation: There are no possible hidden sequences. Thus, we return 0.
+
+
+
+Constraints:
+
+
+ n == differences.length
+ 1 <= n <= 105
+ -105 <= differences[i] <= 105
+ -105 <= lower <= upper <= 105
+
+
+### Related Topics
+ [[Array](../../tag/array/README.md)]
+ [[Prefix Sum](../../tag/prefix-sum/README.md)]
+
+### Hints
+
+Hint 1
+Fix the first element of the hidden sequence to any value x and ignore the given bounds. Notice that we can then determine all the other elements of the sequence by using the differences array.
+
+
+
+Hint 2
+We will also be able to determine the difference between the minimum and maximum elements of the sequence. Notice that the value of x does not affect this.
+
+
+
+Hint 3
+We now have the ‘range’ of the sequence (difference between min and max element), we can then calculate how many ways there are to fit this range into the given range of lower to upper.
+
+
+
+Hint 4
+Answer is (upper - lower + 1) - (range of sequence)
+
diff --git a/problems/count-the-number-of-consistent-strings/README.md b/problems/count-the-number-of-consistent-strings/README.md
index e96a04d61..0149ed188 100644
--- a/problems/count-the-number-of-consistent-strings/README.md
+++ b/problems/count-the-number-of-consistent-strings/README.md
@@ -52,10 +52,10 @@
### Related Topics
+ [[Bit Manipulation](../../tag/bit-manipulation/README.md)]
[[Array](../../tag/array/README.md)]
[[Hash Table](../../tag/hash-table/README.md)]
[[String](../../tag/string/README.md)]
- [[Bit Manipulation](../../tag/bit-manipulation/README.md)]
### Hints
diff --git a/problems/count-the-number-of-experiments/README.md b/problems/count-the-number-of-experiments/README.md
index 004d98070..32f1a9733 100644
--- a/problems/count-the-number-of-experiments/README.md
+++ b/problems/count-the-number-of-experiments/README.md
@@ -9,6 +9,6 @@
[Next >](../find-the-middle-index-in-array "Find the Middle Index in Array")
-## [1990. Count the Number of Experiments (Easy)](https://leetcode.com/problems/count-the-number-of-experiments "")
+## [1990. Count the Number of Experiments (Easy)](https://leetcode.com/problems/count-the-number-of-experiments "统计实验的数量")
diff --git a/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md
index db696b55f..54729a4f0 100644
--- a/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md
+++ b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md
@@ -11,7 +11,7 @@
## [1442. Count Triplets That Can Form Two Arrays of Equal XOR (Medium)](https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor "形成两个异或相等数组的三元组数目")
-Given an array of integers arr.
+Given an array of integers arr.
We want to select three indices i, j and k where (0 <= i < j <= k < arr.length).
@@ -42,33 +42,12 @@
Output: 10
-Example 3:
- --Input: arr = [2,3] -Output: 0 -- -
Example 4:
- --Input: arr = [1,3,5,7,9] -Output: 3 -- -
Example 5:
- --Input: arr = [7,11,12,9,5,2,7,17,22] -Output: 8 --
Constraints:
1 <= arr.length <= 3001 <= arr[i] <= 10^81 <= arr[i] <= 108Example 4:
- --Input: word = "bbaeixoubb" -Output: 0 -Explanation: The only substrings that contain all five vowels also contain consonants, so there are no vowel substrings. +- "cuaieuouac"
diff --git a/problems/count-words-obtained-after-adding-a-letter/README.md b/problems/count-words-obtained-after-adding-a-letter/README.md new file mode 100644 index 000000000..b182d8fbc --- /dev/null +++ b/problems/count-words-obtained-after-adding-a-letter/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../minimum-swaps-to-group-all-1s-together-ii "Minimum Swaps to Group All 1's Together II") + +[Next >](../earliest-possible-day-of-full-bloom "Earliest Possible Day of Full Bloom") + +## [2135. Count Words Obtained After Adding a Letter (Medium)](https://leetcode.com/problems/count-words-obtained-after-adding-a-letter "统计追加字母可以获得的单词数") + +
You are given two 0-indexed arrays of strings startWords and targetWords. Each string consists of lowercase English letters only.
For each string in targetWords, check if it is possible to choose a string from startWords and perform a conversion operation on it to be equal to that from targetWords.
The conversion operation is described in the following two steps:
+ +"abc", the letters 'd', 'e', or 'y' can be added to it, but not 'a'. If 'd' is added, the resulting string will be "abcd"."abcd" can be rearranged to "acbd", "bacd", "cbda", and so on. Note that it can also be rearranged to "abcd" itself.Return the number of strings in targetWords that can be obtained by performing the operations on any string of startWords.
Note that you will only be verifying if the string in targetWords can be obtained from a string in startWords by performing the operations. The strings in startWords do not actually change during this process.
+
Example 1:
+ ++Input: startWords = ["ant","act","tack"], targetWords = ["tack","act","acti"] +Output: 2 +Explanation: +- In order to form targetWords[0] = "tack", we use startWords[1] = "act", append 'k' to it, and rearrange "actk" to "tack". +- There is no string in startWords that can be used to obtain targetWords[1] = "act". + Note that "act" does exist in startWords, but we must append one letter to the string before rearranging it. +- In order to form targetWords[2] = "acti", we use startWords[1] = "act", append 'i' to it, and rearrange "acti" to "acti" itself. ++ +
Example 2:
+ ++Input: startWords = ["ab","a"], targetWords = ["abc","abcd"] +Output: 1 +Explanation: +- In order to form targetWords[0] = "abc", we use startWords[0] = "ab", add 'c' to it, and rearrange it to "abc". +- There is no string in startWords that can be used to obtain targetWords[1] = "abcd". ++ +
+
Constraints:
+ +1 <= startWords.length, targetWords.length <= 5 * 1041 <= startWords[i].length, targetWords[j].length <= 26startWords and targetWords consists of lowercase English letters only.startWords or targetWords.Example 4:
-
--Input: encodedText = " b ac", rows = 2 -Output: " abc" -Explanation: originalText cannot have trailing spaces, but it may be preceded by one or more spaces. --
Constraints:
diff --git a/problems/decode-ways-ii/README.md b/problems/decode-ways-ii/README.md index d8a78212b..7e825db0d 100644 --- a/problems/decode-ways-ii/README.md +++ b/problems/decode-ways-ii/README.md @@ -81,3 +81,4 @@ Hence, there are a total of (6 * 2) + (3 * 1) = 12 + 3 = 15 ways to decode " ### Similar Questions 1. [Decode Ways](../decode-ways) (Medium) 1. [Number of Ways to Separate Numbers](../number-of-ways-to-separate-numbers) (Hard) + 1. [Number of Ways to Divide a Long Corridor](../number-of-ways-to-divide-a-long-corridor) (Hard) diff --git a/problems/decode-xored-permutation/README.md b/problems/decode-xored-permutation/README.md index c848d7942..f1782835e 100644 --- a/problems/decode-xored-permutation/README.md +++ b/problems/decode-xored-permutation/README.md @@ -43,8 +43,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### HintsGiven a string s formed by digits ('0' - '9') and '#' . We want to map s to English lowercase characters as follows:
You are given a string s formed by digits and '#'. We want to map s to English lowercase characters as follows:
'a' to 'i') are represented by ('1' to '9') respectively.'j' to 'z') are represented by ('10#' to '26#') respectively. 'a' to 'i') are represented by ('1' to '9') respectively.'j' to 'z') are represented by ('10#' to '26#') respectively.Return the string formed after mapping.
+Return the string formed after mapping.
-It's guaranteed that a unique mapping will always exist.
+The test cases are generated so that a unique mapping will always exist.
Example 1:
@@ -38,27 +38,13 @@ Output: "acz" -Example 3:
- --Input: s = "25#" -Output: "y" -- -
Example 4:
- --Input: s = "12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#" -Output: "abcdefghijklmnopqrstuvwxyz" --
Constraints:
1 <= s.length <= 1000s[i] only contains digits letters ('0'-'9') and '#' letter.s will be valid string such that mapping is always possible.s consists of digits and the '#' letter.s will be a valid string such that mapping is always possible.Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.
Table: Person
++-------------+---------+ +| Column Name | Type | ++-------------+---------+ +| id | int | +| email | varchar | ++-------------+---------+ +id is the primary key column for this table. +Each row of this table contains an email. The emails will not contain uppercase letters. ++ +
+ +
Write an SQL query to delete all the duplicate emails, keeping only one unique email with the smallest id. Note that you are supposed to write a DELETE statement and not a SELECT one.
Return the result table in any order.
+ +The query result format is in the following example.
+ ++
Example 1:
+ ++Input: +Person table: +----+------------------+ -| Id | Email | +| id | email | +----+------------------+ | 1 | john@example.com | | 2 | bob@example.com | | 3 | john@example.com | +----+------------------+ -Id is the primary key column for this table. -- -
For example, after running your query, the above Person table should have the following rows:
+Output: +----+------------------+ -| Id | Email | +| id | email | +----+------------------+ | 1 | john@example.com | | 2 | bob@example.com | +----+------------------+ +Explanation: john@example.com is repeated two times. We keep the row with the smallest Id = 1.-
Note:
- -Your output is the whole Person table after executing your sql. Use delete statement.
Example 4:
-
--Input: paths = [["a"],["a","x"],["a","x","y"],["a","z"],["b"],["b","x"],["b","x","y"],["b","z"]] -Output: [] -Explanation: The file structure is as shown. -Folders "/a/x" and "/b/x" (and their subfolders) are marked for deletion because they both contain an -empty folder named "y". -Folders "/a" and "/b" (and their subfolders) are marked for deletion because they both contain an empty -folder "z" and the folder "x" described above. -- -
Example 5:
-
--Input: paths = [["a"],["a","x"],["a","x","y"],["a","z"],["b"],["b","x"],["b","x","y"],["b","z"],["b","w"]] -Output: [["b"],["b","w"],["b","z"],["a"],["a","z"]] -Explanation: This has the same structure as the previous example, except with the added "/b/w". -Folders "/a/x" and "/b/x" are still marked, but "/a" and "/b" are no longer marked because "/b" has the -empty folder named "w" and "/a" does not. -Note that "/a/z" and "/b/z" are not marked because the set of identical subfolders must be non-empty, but these folders are empty. --
Constraints:
diff --git a/problems/delete-leaves-with-a-given-value/README.md b/problems/delete-leaves-with-a-given-value/README.md index d581caa4a..1b4d423df 100644 --- a/problems/delete-leaves-with-a-given-value/README.md +++ b/problems/delete-leaves-with-a-given-value/README.md @@ -11,14 +11,14 @@ ## [1325. Delete Leaves With a Given Value (Medium)](https://leetcode.com/problems/delete-leaves-with-a-given-value "删除给定值的叶子节点") -Given a binary tree root and an integer target, delete all the leaf nodes with value target.
Given a binary tree root and an integer target, delete all the leaf nodes with value target.
Note that once you delete a leaf node with value target, if it's parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you can't).
Note that once you delete a leaf node with value target, if its parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you cannot).
Example 1:
-

Input: root = [1,2,3,2,null,2,4], target = 2 @@ -29,7 +29,7 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture inExample 2:
-+
Input: root = [1,3,3,3,2], target = 3 @@ -38,7 +38,7 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture inExample 3:
-+
Input: root = [1,2,null,2,null,2], target = 2 @@ -46,34 +46,19 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in Explanation: Leaf nodes in green with value (target = 2) are removed at each step.-Example 4:
- --Input: root = [1,1,1], target = 1 -Output: [] -- -Example 5:
- --Input: root = [1,2,3], target = 1 -Output: [1,2,3] --
Constraints:
1 <= target <= 10001 and 3000 nodes.[1, 1000].[1, 3000].1 <= Node.val, target <= 1000You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list.
The middle node of a linked list of size n is the ⌊n / 2⌋th node from the start using 0-based indexing, where ⌊x⌋ denotes the largest integer less than or equal to x.
n = 1, 2, 3, 4, and 5, the middle nodes are 0, 1, 1, 2, and 2, respectively.+
Example 1:
+
++Input: head = [1,3,4,7,1,2,6] +Output: [1,3,4,1,2,6] +Explanation: +The above figure represents the given linked list. The indices of the nodes are written below. +Since n = 7, node 3 with value 7 is the middle node, which is marked in red. +We return the new list after removing this node. ++ +
Example 2:
+
++Input: head = [1,2,3,4] +Output: [1,2,4] +Explanation: +The above figure represents the given linked list. +For n = 4, node 2 with value 3 is the middle node, which is marked in red. ++ +
Example 3:
+
++Input: head = [2,1] +Output: [2] +Explanation: +The above figure represents the given linked list. +For n = 2, node 1 with value 1 is the middle node, which is marked in red. +Node 0 with value 2 is the only node remaining after removing node 1.+ +
+
Constraints:
+ +[1, 105].1 <= Node.val <= 105Example 4:
- --Input: boxes = [[2,4],[2,5],[3,1],[3,2],[3,7],[3,1],[4,4],[1,3],[5,2]], portsCount = 5, maxBoxes = 5, maxWeight = 7 -Output: 14 -Explanation: The optimal strategy is as follows: -- The ship takes the first box, goes to port 2, then storage. 2 trips. -- The ship takes the second box, goes to port 2, then storage. 2 trips. -- The ship takes the third and fourth boxes, goes to port 3, then storage. 2 trips. -- The ship takes the fifth box, goes to port 3, then storage. 2 trips. -- The ship takes the sixth and seventh boxes, goes to port 3, then port 4, then storage. 3 trips. -- The ship takes the eighth and ninth boxes, goes to port 1, then port 5, then storage. 3 trips. -So the total number of trips is 2 + 2 + 2 + 2 + 3 + 3 = 14. --
Constraints:
diff --git a/problems/depth-of-bst-given-insertion-order/README.md b/problems/depth-of-bst-given-insertion-order/README.md index 87f0d6196..ecf971b20 100644 --- a/problems/depth-of-bst-given-insertion-order/README.md +++ b/problems/depth-of-bst-given-insertion-order/README.md @@ -9,7 +9,7 @@ [Next >](../largest-odd-number-in-string "Largest Odd Number in String") -## [1902. Depth of BST Given Insertion Order (Medium)](https://leetcode.com/problems/depth-of-bst-given-insertion-order "") +## [1902. Depth of BST Given Insertion Order (Medium)](https://leetcode.com/problems/depth-of-bst-given-insertion-order "给定二叉搜索树的插入顺序求深度") diff --git a/problems/describe-the-painting/README.md b/problems/describe-the-painting/README.md index edda7d60e..ac2cbbea4 100644 --- a/problems/describe-the-painting/README.md +++ b/problems/describe-the-painting/README.md @@ -85,6 +85,10 @@ Note that returning a single segment [1,7) is incorrect because the mixed color [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Average Height of Buildings in Each Segment](../average-height-of-buildings-in-each-segment) (Medium) + 1. [Amount of New Area Painted Each Day](../amount-of-new-area-painted-each-day) (Hard) + ### HintsA Bitset is a data structure that compactly stores bits.
+ +Implement the Bitset class:
Bitset(int size) Initializes the Bitset with size bits, all of which are 0.void fix(int idx) Updates the value of the bit at the index idx to 1. If the value was already 1, no change occurs.void unfix(int idx) Updates the value of the bit at the index idx to 0. If the value was already 0, no change occurs.void flip() Flips the values of each bit in the Bitset. In other words, all bits with value 0 will now have value 1 and vice versa.boolean all() Checks if the value of each bit in the Bitset is 1. Returns true if it satisfies the condition, false otherwise.boolean one() Checks if there is at least one bit in the Bitset with value 1. Returns true if it satisfies the condition, false otherwise.int count() Returns the total number of bits in the Bitset which have value 1.String toString() Returns the current composition of the Bitset. Note that in the resultant string, the character at the ith index should coincide with the value at the ith bit of the Bitset.+
Example 1:
+ ++Input +["Bitset", "fix", "fix", "flip", "all", "unfix", "flip", "one", "unfix", "count", "toString"] +[[5], [3], [1], [], [], [0], [], [], [0], [], []] +Output +[null, null, null, null, false, null, null, true, null, 2, "01010"] + +Explanation +Bitset bs = new Bitset(5); // bitset = "00000". +bs.fix(3); // the value at idx = 3 is updated to 1, so bitset = "00010". +bs.fix(1); // the value at idx = 1 is updated to 1, so bitset = "01010". +bs.flip(); // the value of each bit is flipped, so bitset = "10101". +bs.all(); // return False, as not all values of the bitset are 1. +bs.unfix(0); // the value at idx = 0 is updated to 0, so bitset = "00101". +bs.flip(); // the value of each bit is flipped, so bitset = "11010". +bs.one(); // return True, as there is at least 1 index with value 1. +bs.unfix(0); // the value at idx = 0 is updated to 0, so bitset = "01010". +bs.count(); // return 2, as there are 2 bits with value 1. +bs.toString(); // return "01010", which is the composition of bitset. ++ +
+
Constraints:
+ +1 <= size <= 1050 <= idx <= size - 1105 calls will be made in total to fix, unfix, flip, all, one, count, and toString.all, one, count, or toString.5 calls will be made to toString.You are given an integer mass, which represents the original mass of a planet. You are further given an integer array asteroids, where asteroids[i] is the mass of the ith asteroid.
You can arrange for the planet to collide with the asteroids in any arbitrary order. If the mass of the planet is greater than or equal to the mass of the asteroid, the asteroid is destroyed and the planet gains the mass of the asteroid. Otherwise, the planet is destroyed.
+ +Return true if all asteroids can be destroyed. Otherwise, return false.
+
Example 1:
+ ++Input: mass = 10, asteroids = [3,9,19,5,21] +Output: true +Explanation: One way to order the asteroids is [9,19,5,3,21]: +- The planet collides with the asteroid with a mass of 9. New planet mass: 10 + 9 = 19 +- The planet collides with the asteroid with a mass of 19. New planet mass: 19 + 19 = 38 +- The planet collides with the asteroid with a mass of 5. New planet mass: 38 + 5 = 43 +- The planet collides with the asteroid with a mass of 3. New planet mass: 43 + 3 = 46 +- The planet collides with the asteroid with a mass of 21. New planet mass: 46 + 21 = 67 +All asteroids are destroyed. ++ +
Example 2:
+ ++Input: mass = 5, asteroids = [4,9,23,4] +Output: false +Explanation: +The planet cannot ever gain enough mass to destroy the asteroid with a mass of 23. +After the planet destroys the other asteroids, it will have a mass of 5 + 4 + 9 + 4 = 22. +This is less than 23, so a collision would not destroy the last asteroid.+ +
+
Constraints:
+ +1 <= mass <= 1051 <= asteroids.length <= 1051 <= asteroids[i] <= 105Given an array of positive integers arr, find a pattern of length m that is repeated k or more times.
Given an array of positive integers arr, find a pattern of length m that is repeated k or more times.
A pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times consecutively without overlapping. A pattern is defined by its length and the number of repetitions.
-Return true if there exists a pattern of length m that is repeated k or more times, otherwise return false.
Return true if there exists a pattern of length m that is repeated k or more times, otherwise return false.
Example 1:
@@ -42,36 +42,23 @@ Explanation: The pattern (1,2) is of length 2 but is repeated only 2 times. There is no pattern of length 2 that is repeated 3 or more times. -Example 4:
- --Input: arr = [1,2,3,1,2], m = 2, k = 2 -Output: false -Explanation: Notice that the pattern (1,2) exists twice but not consecutively, so it doesn't count. -- -
Example 5:
- --Input: arr = [2,2,2,2], m = 2, k = 3 -Output: false -Explanation: The only pattern of length 2 is (2,2) however it's repeated only twice. Notice that we do not count overlapping repetitions. --
Constraints:
2 <= arr.length <= 1001 <= arr[i] <= 1001 <= m <= 1002 <= k <= 1001 <= m <= 1002 <= k <= 100Input: s = "book" Output: true -Explanation: a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike. +Explanation: a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike.
Example 2:
@@ -31,24 +31,10 @@Input: s = "textbook" Output: false -Explanation: a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike. +Explanation: a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike. Notice that the vowel o is counted twice.-
Example 3:
- --Input: s = "MerryChristmas" -Output: false -- -
Example 4:
- --Input: s = "AbCdEfGh" -Output: true --
Constraints:
diff --git a/problems/determine-if-two-strings-are-close/README.md b/problems/determine-if-two-strings-are-close/README.md index 9da101df9..a6740f403 100644 --- a/problems/determine-if-two-strings-are-close/README.md +++ b/problems/determine-if-two-strings-are-close/README.md @@ -60,14 +60,6 @@ Apply Operation 1: "cabbba" -> "caabbb Apply Operation 2: "baaccc" -> "abbccc" -Example 4:
- --Input: word1 = "cabbba", word2 = "aabbss" -Output: false -Explanation: It is impossible to attain word2 from word1, or vice versa, in any amount of operations. --
Constraints:
@@ -81,11 +73,6 @@ Apply Operation 2: "baaccc" -> "abbccc" [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Buddy Strings](../buddy-strings) (Easy) - 1. [Minimum Swaps to Make Strings Equal](../minimum-swaps-to-make-strings-equal) (Medium) - 1. [Minimum Number of Steps to Make Two Strings Anagram](../minimum-number-of-steps-to-make-two-strings-anagram) (Medium) - ### HintsYou are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb.
+ +The bombs are represented by a 0-indexed 2D integer array bombs where bombs[i] = [xi, yi, ri]. xi and yi denote the X-coordinate and Y-coordinate of the location of the ith bomb, whereas ri denotes the radius of its range.
You may choose to detonate a single bomb. When a bomb is detonated, it will detonate all bombs that lie in its range. These bombs will further detonate the bombs that lie in their ranges.
+ +Given the list of bombs, return the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb.
+
Example 1:
+
++Input: bombs = [[2,1,3],[6,1,4]] +Output: 2 +Explanation: +The above figure shows the positions and ranges of the 2 bombs. +If we detonate the left bomb, the right bomb will not be affected. +But if we detonate the right bomb, both bombs will be detonated. +So the maximum bombs that can be detonated is max(1, 2) = 2. ++ +
Example 2:
+
++Input: bombs = [[1,1,5],[10,10,5]] +Output: 1 +Explanation: +Detonating either bomb will not detonate the other bomb, so the maximum number of bombs that can be detonated is 1. ++ +
Example 3:
+
++Input: bombs = [[1,2,3],[2,3,1],[3,4,2],[4,5,3],[5,6,4]] +Output: 5 +Explanation: +The best bomb to detonate is bomb 0 because: +- Bomb 0 detonates bombs 1 and 2. The red circle denotes the range of bomb 0. +- Bomb 2 detonates bomb 3. The blue circle denotes the range of bomb 2. +- Bomb 3 detonates bomb 4. The green circle denotes the range of bomb 3. +Thus all 5 bombs are detonated. ++ +
+
Constraints:
+ +1 <= bombs.length <= 100bombs[i].length == 31 <= xi, yi, ri <= 105nums, return all elements of nums in diagonal order as shown in the below images.
+Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.
Example 1:
- -
Input: nums = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,4,2,7,5,3,8,6,9]
Example 2:
- -
Input: nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]] Output: [1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16]-
Example 3:
- --Input: nums = [[1,2,3],[4],[5,6,7],[8],[9,10,11]] -Output: [1,4,2,5,3,8,6,9,7,10,11] -- -
Example 4:
- --Input: nums = [[1,2,3,4,5,6]] -Output: [1,2,3,4,5,6] --
Constraints:
1 <= nums.length <= 10^51 <= nums[i].length <= 10^51 <= nums[i][j] <= 10^910^5 elements in nums.1 <= nums.length <= 1051 <= nums[i].length <= 1051 <= sum(nums[i].length) <= 1051 <= nums[i][j] <= 105
Example 1:
-
+
Input: root = [3,0,0] Output: 2 @@ -27,27 +27,13 @@
Example 2:
-
+
Input: root = [0,3,0] Output: 3 Explanation: From the left child of the root, we move two coins to the root [taking two moves]. Then, we move one coin from the root of the tree to the right child.-
Example 3:
-
--Input: root = [1,0,2] -Output: 2 -- -
Example 4:
-
--Input: root = [1,0,0,null,3] -Output: 4 --
Constraints:
diff --git a/problems/distribute-repeating-integers/README.md b/problems/distribute-repeating-integers/README.md index aa9699270..c9c238bd3 100644 --- a/problems/distribute-repeating-integers/README.md +++ b/problems/distribute-repeating-integers/README.md @@ -27,7 +27,7 @@Input: nums = [1,2,3,4], quantity = [2] Output: false -Explanation: The 0th customer cannot be given two different integers. +Explanation: The 0th customer cannot be given two different integers.
Example 2:
@@ -35,7 +35,7 @@Input: nums = [1,2,3,3], quantity = [2] Output: true -Explanation: The 0th customer is given [3,3]. The integers [1,2] are not used. +Explanation: The 0th customer is given [3,3]. The integers [1,2] are not used.
Example 3:
@@ -43,22 +43,7 @@Input: nums = [1,1,2,2], quantity = [2,2] Output: true -Explanation: The 0th customer is given [1,1], and the 1st customer is given [2,2]. -- -
Example 4:
- --Input: nums = [1,1,2,3], quantity = [2,2] -Output: false -Explanation: Although the 0th customer could be given [1,1], the 1st customer cannot be satisfied.- -
Example 5:
- --Input: nums = [1,1,1,1,1], quantity = [2,3] -Output: true -Explanation: The 0th customer is given [1,1], and the 1st customer is given [1,1,1]. +Explanation: The 0th customer is given [1,1], and the 1st customer is given [2,2].
diff --git a/problems/divide-a-string-into-groups-of-size-k/README.md b/problems/divide-a-string-into-groups-of-size-k/README.md new file mode 100644 index 000000000..f7fc58e35 --- /dev/null +++ b/problems/divide-a-string-into-groups-of-size-k/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../pour-water-between-buckets-to-make-water-levels-equal "Pour Water Between Buckets to Make Water Levels Equal") + +[Next >](../minimum-moves-to-reach-target-score "Minimum Moves to Reach Target Score") + +## [2138. Divide a String Into Groups of Size k (Easy)](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k "将字符串拆分为若干长度为 k 的组") + +
A string s can be partitioned into groups of size k using the following procedure:
k characters of the string, the second group consists of the next k characters of the string, and so on. Each character can be a part of exactly one group.k characters remaining, a character fill is used to complete the group.Note that the partition is done so that after removing the fill character from the last group (if it exists) and concatenating all the groups in order, the resultant string should be s.
Given the string s, the size of each group k and the character fill, return a string array denoting the composition of every group s has been divided into, using the above procedure.
+
Example 1:
+ ++Input: s = "abcdefghi", k = 3, fill = "x" +Output: ["abc","def","ghi"] +Explanation: +The first 3 characters "abc" form the first group. +The next 3 characters "def" form the second group. +The last 3 characters "ghi" form the third group. +Since all groups can be completely filled by characters from the string, we do not need to use fill. +Thus, the groups formed are "abc", "def", and "ghi". ++ +
Example 2:
+ ++Input: s = "abcdefghij", k = 3, fill = "x" +Output: ["abc","def","ghi","jxx"] +Explanation: +Similar to the previous example, we are forming the first three groups "abc", "def", and "ghi". +For the last group, we can only use the character 'j' from the string. To complete this group, we add 'x' twice. +Thus, the 4 groups formed are "abc", "def", "ghi", and "jxx". ++ +
+
Constraints:
+ +1 <= s.length <= 100s consists of lowercase English letters only.1 <= k <= 100fill is a lowercase English letter.You have n flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two 0-indexed integer arrays plantTime and growTime, of length n each:
plantTime[i] is the number of full days it takes you to plant the ith seed. Every day, you can work on planting exactly one seed. You do not have to work on planting the same seed on consecutive days, but the planting of a seed is not complete until you have worked plantTime[i] days on planting it in total.growTime[i] is the number of full days it takes the ith seed to grow after being completely planted. After the last day of its growth, the flower blooms and stays bloomed forever.From the beginning of day 0, you can plant the seeds in any order.
Return the earliest possible day where all seeds are blooming.
+ ++
Example 1:
+
++Input: plantTime = [1,4,3], growTime = [2,3,1] +Output: 9 +Explanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms. +One optimal way is: +On day 0, plant the 0th seed. The seed grows for 2 full days and blooms on day 3. +On days 1, 2, 3, and 4, plant the 1st seed. The seed grows for 3 full days and blooms on day 8. +On days 5, 6, and 7, plant the 2nd seed. The seed grows for 1 full day and blooms on day 9. +Thus, on day 9, all the seeds are blooming. ++ +
Example 2:
+
++Input: plantTime = [1,2,3,2], growTime = [2,1,2,1] +Output: 9 +Explanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms. +One optimal way is: +On day 1, plant the 0th seed. The seed grows for 2 full days and blooms on day 4. +On days 0 and 3, plant the 1st seed. The seed grows for 1 full day and blooms on day 5. +On days 2, 4, and 5, plant the 2nd seed. The seed grows for 2 full days and blooms on day 8. +On days 6 and 7, plant the 3rd seed. The seed grows for 1 full day and blooms on day 9. +Thus, on day 9, all the seeds are blooming. ++ +
Example 3:
+ ++Input: plantTime = [1], growTime = [1] +Output: 2 +Explanation: On day 0, plant the 0th seed. The seed grows for 1 full day and blooms on day 2. +Thus, on day 2, all the seeds are blooming. ++ +
+
Constraints:
+ +n == plantTime.length == growTime.length1 <= n <= 1051 <= plantTime[i], growTime[i] <= 104Example 4:
- --Input: s = "(a)(b)", knowledge = [["a","b"],["b","a"]] -Output: "ba"-
Constraints:
diff --git a/problems/even-odd-tree/README.md b/problems/even-odd-tree/README.md index 2cbc1f3a2..733b0e483 100644 --- a/problems/even-odd-tree/README.md +++ b/problems/even-odd-tree/README.md @@ -23,9 +23,7 @@
Example 1:
- -
Input: root = [1,10,4,3,null,7,9,12,8,6,null,null,2] Output: true @@ -34,13 +32,11 @@ Level 0: [1] Level 1: [10,4] Level 2: [3,7,9] Level 3: [12,8,6,2] -Since levels 0 and 2 are all odd and increasing, and levels 1 and 3 are all even and decreasing, the tree is Even-Odd. +Since levels 0 and 2 are all odd and increasing and levels 1 and 3 are all even and decreasing, the tree is Even-Odd.
Example 2:
- -
Input: root = [5,4,2,3,3,7] Output: false @@ -48,33 +44,17 @@ Since levels 0 and 2 are all odd and increasing, and levels 1 and 3 are all even Level 0: [5] Level 1: [4,2] Level 2: [3,3,7] -Node values in the level 2 must be in strictly increasing order, so the tree is not Even-Odd. +Node values in level 2 must be in strictly increasing order, so the tree is not Even-Odd.
Example 3:
- -
Input: root = [5,9,1,3,5,7] Output: false Explanation: Node values in the level 1 should be even integers.-
Example 4:
- --Input: root = [1] -Output: true -- -
Example 5:
- --Input: root = [11,8,6,1,3,9,11,30,20,18,16,12,10,4,2,17] -Output: true --
Constraints:
diff --git a/problems/excel-sheet-column-number/README.md b/problems/excel-sheet-column-number/README.md index 2db81257f..dad535777 100644 --- a/problems/excel-sheet-column-number/README.md +++ b/problems/excel-sheet-column-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum-iii-data-structure-design "Two Sum III - Data structure design") @@ -48,13 +48,6 @@ AB -> 28 Output: 701 -Example 4:
- --Input: columnTitle = "FXSHRXW" -Output: 2147483647 --
Constraints:
diff --git a/problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md b/problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md new file mode 100644 index 000000000..b462fe8ea --- /dev/null +++ b/problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../a-number-after-a-double-reversal "A Number After a Double Reversal") + +[Next >](../intervals-between-identical-elements "Intervals Between Identical Elements") + +## [2120. Execution of All Suffix Instructions Staying in a Grid (Medium)](https://leetcode.com/problems/execution-of-all-suffix-instructions-staying-in-a-grid "执行所有后缀指令") + +There is an n x n grid, with the top-left cell at (0, 0) and the bottom-right cell at (n - 1, n - 1). You are given the integer n and an integer array startPos where startPos = [startrow, startcol] indicates that a robot is initially at cell (startrow, startcol).
You are also given a 0-indexed string s of length m where s[i] is the ith instruction for the robot: 'L' (move left), 'R' (move right), 'U' (move up), and 'D' (move down).
The robot can begin executing from any ith instruction in s. It executes the instructions one by one towards the end of s but it stops if either of these conditions is met:
Return an array answer of length m where answer[i] is the number of instructions the robot can execute if the robot begins executing from the ith instruction in s.
+
Example 1:
+
++Input: n = 3, startPos = [0,1], s = "RRDDLU" +Output: [1,5,4,3,1,0] +Explanation: Starting from startPos and beginning execution from the ith instruction: +- 0th: "RRDDLU". Only one instruction "R" can be executed before it moves off the grid. +- 1st: "RDDLU". All five instructions can be executed while it stays in the grid and ends at (1, 1). +- 2nd: "DDLU". All four instructions can be executed while it stays in the grid and ends at (1, 0). +- 3rd: "DLU". All three instructions can be executed while it stays in the grid and ends at (0, 0). +- 4th: "LU". Only one instruction "L" can be executed before it moves off the grid. +- 5th: "U". If moving up, it would move off the grid. ++ +
Example 2:
+
++Input: n = 2, startPos = [1,1], s = "LURD" +Output: [4,1,0,0] +Explanation: +- 0th: "LURD". +- 1st: "URD". +- 2nd: "RD". +- 3rd: "D". ++ +
Example 3:
+
++Input: n = 1, startPos = [0,0], s = "LRUD" +Output: [0,0,0,0] +Explanation: No matter which instruction the robot begins execution from, it would move off the grid. ++ +
+
Constraints:
+ +m == s.length1 <= n, m <= 500startPos.length == 20 <= startrow, startcol < ns consists of 'L', 'R', 'U', and 'D'.Alice and Bob have a different total number of candies. You are given two integer arrays aliceSizes and bobSizes where aliceSizes[i] is the number of candies of the ith box of candy that Alice has and bobSizes[j] is the number of candies of the jth box of candy that Bob has.
Example 4:
- --Input: aliceSizes = [1,2,5], bobSizes = [2,4] -Output: [5,4] --
Constraints:
diff --git a/problems/filling-bookcase-shelves/README.md b/problems/filling-bookcase-shelves/README.md index 7906d6302..c6cf32c76 100644 --- a/problems/filling-bookcase-shelves/README.md +++ b/problems/filling-bookcase-shelves/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-in-zigzag-labelled-binary-tree "Path In Zigzag Labelled Binary Tree") diff --git a/problems/final-prices-with-a-special-discount-in-a-shop/README.md b/problems/final-prices-with-a-special-discount-in-a-shop/README.md index 25c0fa2da..7c6538477 100644 --- a/problems/final-prices-with-a-special-discount-in-a-shop/README.md +++ b/problems/final-prices-with-a-special-discount-in-a-shop/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-n-nodes-after-m-nodes-of-a-linked-list "Delete N Nodes After M Nodes of a Linked List") diff --git a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md index 84e1c95e2..66b06bfd1 100644 --- a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md +++ b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-employee-id-with-the-unique-identifier "Replace Employee ID With The Unique Identifier") @@ -42,20 +42,6 @@ Output: 4 -Example 4:
-
--Input: tree = [1,2,3,4,5,6,7,8,9,10], target = 5 -Output: 5 -- -
Example 5:
-
--Input: tree = [1,2,null,3], target = 2 -Output: 2 --
Constraints:
diff --git a/problems/find-a-peak-element-ii/README.md b/problems/find-a-peak-element-ii/README.md index cdf0afb44..c47255627 100644 --- a/problems/find-a-peak-element-ii/README.md +++ b/problems/find-a-peak-element-ii/README.md @@ -57,6 +57,9 @@ [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Find Peak Element](../find-peak-element) (Medium) + ### HintsYou are given an integer array nums. A number x is lonely when it appears only once, and no adjacent numbers (i.e. x + 1 and x - 1) appear in the array.
Return all lonely numbers in nums. You may return the answer in any order.
+
Example 1:
+ ++Input: nums = [10,6,5,8] +Output: [10,8] +Explanation: +- 10 is a lonely number since it appears exactly once and 9 and 11 does not appear in nums. +- 8 is a lonely number since it appears exactly once and 7 and 9 does not appear in nums. +- 5 is not a lonely number since 6 appears in nums and vice versa. +Hence, the lonely numbers in nums are [10, 8]. +Note that [8, 10] may also be returned. ++ +
Example 2:
+ ++Input: nums = [1,3,5,3] +Output: [1,5] +Explanation: +- 1 is a lonely number since it appears exactly once and 0 and 2 does not appear in nums. +- 5 is a lonely number since it appears exactly once and 4 and 6 does not appear in nums. +- 3 is not a lonely number since it appears twice. +Hence, the lonely numbers in nums are [1, 5]. +Note that [5, 1] may also be returned. ++ +
+
Constraints:
+ +1 <= nums.length <= 1050 <= nums[i] <= 106You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [xi, yi, timei] indicates that person xi and person yi have a meeting at timei. A person may attend multiple meetings at the same time. Finally, you are given an integer firstPerson.
Person 0 has a secret and initially shares the secret with a person firstPerson at time 0. This secret is then shared every time a meeting takes place with a person that has the secret. More formally, for every meeting, if a person xi has the secret at timei, then they will share the secret with person yi, and vice versa.
The secrets are shared instantaneously. That is, a person may receive the secret and share it with people in other meetings within the same time frame.
+ +Return a list of all the people that have the secret after all the meetings have taken place. You may return the answer in any order.
+ ++
Example 1:
+ ++Input: n = 6, meetings = [[1,2,5],[2,3,8],[1,5,10]], firstPerson = 1 +Output: [0,1,2,3,5] +Explanation: +At time 0, person 0 shares the secret with person 1. +At time 5, person 1 shares the secret with person 2. +At time 8, person 2 shares the secret with person 3. +At time 10, person 1 shares the secret with person 5. +Thus, people 0, 1, 2, 3, and 5 know the secret after all the meetings. ++ +
Example 2:
+ ++Input: n = 4, meetings = [[3,1,3],[1,2,2],[0,3,3]], firstPerson = 3 +Output: [0,1,3] +Explanation: +At time 0, person 0 shares the secret with person 3. +At time 2, neither person 1 nor person 2 know the secret. +At time 3, person 3 shares the secret with person 0 and person 1. +Thus, people 0, 1, and 3 know the secret after all the meetings. ++ +
Example 3:
+ ++Input: n = 5, meetings = [[3,4,2],[1,2,1],[2,3,1]], firstPerson = 1 +Output: [0,1,2,3,4] +Explanation: +At time 0, person 0 shares the secret with person 1. +At time 1, person 1 shares the secret with person 2, and person 2 shares the secret with person 3. +Note that person 2 can share the secret at the same time as receiving it. +At time 2, person 3 shares the secret with person 4. +Thus, people 0, 1, 2, 3, and 4 know the secret after all the meetings. ++ +
+
Constraints:
+ +2 <= n <= 1051 <= meetings.length <= 105meetings[i].length == 30 <= xi, yi <= n - 1xi != yi1 <= timei <= 1051 <= firstPerson <= n - 1You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name recipes[i], and you can create it if you have all the needed ingredients from ingredients[i]. Ingredients to a recipe may need to be created from other recipes, i.e., ingredients[i] may contain a string that is in recipes.
You are also given a string array supplies containing all the ingredients that you initially have, and you have an infinite supply of all of them.
Return a list of all the recipes that you can create. You may return the answer in any order.
+ +Note that two recipes may contain each other in their ingredients.
+ ++
Example 1:
+ ++Input: recipes = ["bread"], ingredients = [["yeast","flour"]], supplies = ["yeast","flour","corn"] +Output: ["bread"] +Explanation: +We can create "bread" since we have the ingredients "yeast" and "flour". ++ +
Example 2:
+ ++Input: recipes = ["bread","sandwich"], ingredients = [["yeast","flour"],["bread","meat"]], supplies = ["yeast","flour","meat"] +Output: ["bread","sandwich"] +Explanation: +We can create "bread" since we have the ingredients "yeast" and "flour". +We can create "sandwich" since we have the ingredient "meat" and can create the ingredient "bread". ++ +
Example 3:
+ ++Input: recipes = ["bread","sandwich","burger"], ingredients = [["yeast","flour"],["bread","meat"],["sandwich","meat","bread"]], supplies = ["yeast","flour","meat"] +Output: ["bread","sandwich","burger"] +Explanation: +We can create "bread" since we have the ingredients "yeast" and "flour". +We can create "sandwich" since we have the ingredient "meat" and can create the ingredient "bread". +We can create "burger" since we have the ingredient "meat" and can create the ingredients "bread" and "sandwich". ++ +
+
Constraints:
+ +n == recipes.length == ingredients.length1 <= n <= 1001 <= ingredients[i].length, supplies.length <= 1001 <= recipes[i].length, ingredients[i][j].length, supplies[k].length <= 10recipes[i], ingredients[i][j], and supplies[k] consist only of lowercase English letters.recipes and supplies combined are unique.ingredients[i] does not contain any duplicate values.Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.
Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value.
If target is not found in the array, return [-1, -1].
Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string "".
A string is palindromic if it reads the same forward and backward.
+ ++
Example 1:
+ ++Input: words = ["abc","car","ada","racecar","cool"] +Output: "ada" +Explanation: The first string that is palindromic is "ada". +Note that "racecar" is also palindromic, but it is not the first. ++ +
Example 2:
+ ++Input: words = ["notapalindrome","racecar"] +Output: "racecar" +Explanation: The first and only string that is palindromic is "racecar". ++ +
Example 3:
+ ++Input: words = ["def","ghi"] +Output: "" +Explanation: There are no palindromic strings, so the empty string is returned. ++ +
+
Constraints:
+ +1 <= words.length <= 1001 <= words[i].length <= 100words[i] consists only of lowercase English letters.You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the ith day. The days are numbered starting from 0. You are also given an integer time.
The ith day is a good day to rob the bank if:
time days before and after the ith day,time days before i are non-increasing, andtime days after i are non-decreasing.More formally, this means day i is a good day to rob the bank if and only if security[i - time] >= security[i - time + 1] >= ... >= security[i] <= ... <= security[i + time - 1] <= security[i + time].
Return a list of all days (0-indexed) that are good days to rob the bank. The order that the days are returned in does not matter.
+ ++
Example 1:
+ ++Input: security = [5,3,3,3,5,6,2], time = 2 +Output: [2,3] +Explanation: +On day 2, we have security[0] >= security[1] >= security[2] <= security[3] <= security[4]. +On day 3, we have security[1] >= security[2] >= security[3] <= security[4] <= security[5]. +No other days satisfy this condition, so days 2 and 3 are the only good days to rob the bank. ++ +
Example 2:
+ ++Input: security = [1,1,1,1,1], time = 0 +Output: [0,1,2,3,4] +Explanation: +Since time equals 0, every day is a good day to rob the bank, so return every day. ++ +
Example 3:
+ ++Input: security = [1,2,3,4,5,6], time = 2 +Output: [] +Explanation: +No day has 2 days before it that have a non-increasing number of guards. +Thus, no day is a good day to rob the bank, so return an empty list. ++ +
+
Constraints:
+ +1 <= security.length <= 1050 <= security[i], time <= 105There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself.
You want to determine if there is a valid path that exists from vertex start to vertex end.
You want to determine if there is a valid path that exists from vertex source to vertex destination.
Given edges and the integers n, start, and end, return true if there is a valid path from start to end, or false otherwise.
Given edges and the integers n, source, and destination, return true if there is a valid path from source to destination, or false otherwise.
Example 1:
-Input: n = 3, edges = [[0,1],[1,2],[2,0]], start = 0, end = 2 +Input: n = 3, edges = [[0,1],[1,2],[2,0]], source = 0, destination = 2 Output: true Explanation: There are two paths from vertex 0 to vertex 2: - 0 → 1 → 2 @@ -31,7 +31,7 @@Example 2:
-Input: n = 6, edges = [[0,1],[0,2],[3,5],[5,4],[4,3]], start = 0, end = 5 +Input: n = 6, edges = [[0,1],[0,2],[3,5],[5,4],[4,3]], source = 0, destination = 5 Output: false Explanation: There is no path from vertex 0 to vertex 5.@@ -45,7 +45,7 @@
edges[i].length == 20 <= ui, vi <= n - 1ui != vi0 <= start, end <= n - 10 <= source, destination <= n - 1S1 = "0"Si = Si-1 + "1" + reverse(invert(Si-1)) for i > 1Si = Si - 1 + "1" + reverse(invert(Si - 1)) for i > 1Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).
Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).
For example, the first 4 strings in the above sequence are:
+For example, the first four strings in the above sequence are:
S1 = "0"Input: n = 3, k = 1 Output: "0" -Explanation: S3 is "0111001". The first bit is "0". +Explanation: S3 is "0111001". +The 1st bit is "0".
Example 2:
@@ -45,21 +46,8 @@Input: n = 4, k = 11 Output: "1" -Explanation: S4 is "011100110110001". The 11th bit is "1". -- -
Example 3:
- --Input: n = 1, k = 1 -Output: "0" -- -
Example 4:
- --Input: n = 2, k = 3 -Output: "1" +Explanation: S4 is "011100110110001". +The 11th bit is "1".
diff --git a/problems/find-kth-largest-xor-coordinate-value/README.md b/problems/find-kth-largest-xor-coordinate-value/README.md index 09a8dc816..1e1e0f942 100644 --- a/problems/find-kth-largest-xor-coordinate-value/README.md +++ b/problems/find-kth-largest-xor-coordinate-value/README.md @@ -23,14 +23,16 @@
Input: matrix = [[5,2],[1,6]], k = 1 Output: 7 -Explanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value.+Explanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value. +
Example 2:
Input: matrix = [[5,2],[1,6]], k = 2 Output: 5 -Explanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value.+Explanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value. +
Example 3:
@@ -39,13 +41,6 @@ Output: 4 Explanation: The value of coordinate (1,0) is 5 XOR 1 = 4, which is the 3rd largest value. -Example 4:
- --Input: matrix = [[5,2],[1,6]], k = 4 -Output: 0 -Explanation: The value of coordinate (1,1) is 5 XOR 2 XOR 1 XOR 6 = 0, which is the 4th largest value.-
Constraints:
diff --git a/problems/find-latest-group-of-size-m/README.md b/problems/find-latest-group-of-size-m/README.md index 7b8f9ad12..a9082fdad 100644 --- a/problems/find-latest-group-of-size-m/README.md +++ b/problems/find-latest-group-of-size-m/README.md @@ -25,21 +25,22 @@Input: arr = [3,5,1,2,4], m = 1 Output: 4 -Explanation: -Step 1: "00100", groups: ["1"] +Explanation: +Step 1: "00100", groups: ["1"] Step 2: "00101", groups: ["1", "1"] Step 3: "10101", groups: ["1", "1", "1"] Step 4: "11101", groups: ["111", "1"] Step 5: "11111", groups: ["11111"] -The latest step at which there exists a group of size 1 is step 4.+The latest step at which there exists a group of size 1 is step 4. +
Example 2:
Input: arr = [3,1,5,4,2], m = 2 Output: -1 -Explanation: -Step 1: "00100", groups: ["1"] +Explanation: +Step 1: "00100", groups: ["1"] Step 2: "10100", groups: ["1", "1"] Step 3: "10101", groups: ["1", "1", "1"] Step 4: "10111", groups: ["1", "111"] @@ -47,20 +48,6 @@ Step 5: "11111", groups: ["11111"] No group of size 2 exists during any step.-
Example 3:
- --Input: arr = [1], m = 1 -Output: 1 -- -
Example 4:
- --Input: arr = [2,1], m = 2 -Output: 2 --
Constraints:
diff --git a/problems/find-longest-awesome-substring/README.md b/problems/find-longest-awesome-substring/README.md index 35bff6ebc..b024ca96d 100644 --- a/problems/find-longest-awesome-substring/README.md +++ b/problems/find-longest-awesome-substring/README.md @@ -11,9 +11,9 @@ ## [1542. Find Longest Awesome Substring (Hard)](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") -Given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it palindrome.
You are given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it a palindrome.
Return the length of the maximum length awesome substring of s.
Return the length of the maximum length awesome substring of s.
Example 1:
@@ -39,13 +39,6 @@ Explanation: "213123" is the longest awesome substring, we can form the palindrome "231132" with some swaps. -Example 4:
- --Input: s = "00" -Output: 2 --
Constraints:
diff --git a/problems/find-lucky-integer-in-an-array/README.md b/problems/find-lucky-integer-in-an-array/README.md index 2308ca8e0..197c818bd 100644 --- a/problems/find-lucky-integer-in-an-array/README.md +++ b/problems/find-lucky-integer-in-an-array/README.md @@ -11,9 +11,9 @@ ## [1394. Find Lucky Integer in an Array (Easy)](https://leetcode.com/problems/find-lucky-integer-in-an-array "找出数组中的幸运数") -Given an array of integers arr, a lucky integer is an integer which has a frequency in the array equal to its value.
Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value.
Return a lucky integer in the array. If there are multiple lucky integers return the largest of them. If there is no lucky integer return -1.
+Return the largest lucky integer in the array. If there is no lucky integer return -1.
Example 1:
@@ -40,20 +40,6 @@ Explanation: There are no lucky numbers in the array. -Example 4:
- --Input: arr = [5] -Output: -1 -- -
Example 5:
- --Input: arr = [7,7,7,7,7,7,7] -Output: 7 --
Constraints:
diff --git a/problems/find-minimum-in-rotated-sorted-array-ii/README.md b/problems/find-minimum-in-rotated-sorted-array-ii/README.md index d9cf6cda9..5fa38008e 100644 --- a/problems/find-minimum-in-rotated-sorted-array-ii/README.md +++ b/problems/find-minimum-in-rotated-sorted-array-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-minimum-in-rotated-sorted-array "Find Minimum in Rotated Sorted Array") diff --git a/problems/find-missing-observations/README.md b/problems/find-missing-observations/README.md index 7509a72d7..65ccb1f6d 100644 --- a/problems/find-missing-observations/README.md +++ b/problems/find-missing-observations/README.md @@ -46,14 +46,6 @@ Explanation: It is impossible for the mean to be 6 no matter what the 4 missing rolls are. -Example 4:
- --Input: rolls = [1], mean = 3, n = 1 -Output: [5] -Explanation: The mean of all n + m rolls is (1 + 5) / 2 = 3. --
Constraints:
diff --git a/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md index 428b9c620..f390364e6 100644 --- a/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md +++ b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md @@ -51,6 +51,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [K Closest Points to Origin](../k-closest-points-to-origin) (Medium) + ### HintsInput: k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] Output: [1] -Explanation: +Explanation: All of the servers start out available. The first 3 requests are handled by the first 3 servers in order. Request 3 comes in. Server 0 is busy, so it's assigned to the next available server, which is 1. @@ -43,7 +43,7 @@ Servers 0 and 2 handled one request each, while server 1 handled two requests. H-Input: k = 3, arrival = [1,2,3,4], load = [1,2,1,2] Output: [0] -Explanation: +Explanation: The first 3 requests are handled by first 3 servers. Request 3 comes in. It is handled by server 0 since the server is available. Server 0 handled two requests, while servers 1 and 2 handled one request each. Hence server 0 is the busiest server. @@ -54,21 +54,7 @@ Server 0 handled two requests, while servers 1 and 2 handled one request each. HInput: k = 3, arrival = [1,2,3], load = [10,12,11] Output: [0,1,2] -Explanation: Each server handles a single request, so they are all considered the busiest. -- -Example 4:
- --Input: k = 3, arrival = [1,2,3,4,8,9,10], load = [5,2,10,3,1,2,2] -Output: [1] -- -Example 5:
- --Input: k = 1, arrival = [1], load = [1] -Output: [0] +Explanation: Each server handles a single request, so they are all considered the busiest.@@ -83,10 +69,10 @@ Server 0 handled two requests, while servers 1 and 2 handled one request each. H ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Hints
diff --git a/problems/find-subsequence-of-length-k-with-the-largest-sum/README.md b/problems/find-subsequence-of-length-k-with-the-largest-sum/README.md new file mode 100644 index 000000000..dcdab30b2 --- /dev/null +++ b/problems/find-subsequence-of-length-k-with-the-largest-sum/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../subsequence-of-size-k-with-the-largest-even-sum "Subsequence of Size K With the Largest Even Sum") + +[Next >](../find-good-days-to-rob-the-bank "Find Good Days to Rob the Bank") + +## [2099. Find Subsequence of Length K With the Largest Sum (Easy)](https://leetcode.com/problems/find-subsequence-of-length-k-with-the-largest-sum "找到和最大的长度为 K 的子序列") + +You are given an integer array
+ +numsand an integerk. You want to find a subsequence ofnumsof lengthkthat has the largest sum.Return any such subsequence as an integer array of length
+ +k.A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.
+ ++
Example 1:
+ ++Input: nums = [2,1,3,3], k = 2 +Output: [3,3] +Explanation: +The subsequence has the largest sum of 3 + 3 = 6.+ +Example 2:
+ ++Input: nums = [-1,-2,3,4], k = 3 +Output: [-1,3,4] +Explanation: +The subsequence has the largest sum of -1 + 3 + 4 = 6. ++ +Example 3:
+ ++Input: nums = [3,4,3,3], k = 2 +Output: [3,4] +Explanation: +The subsequence has the largest sum of 3 + 4 = 7. +Another possible subsequence is [4, 3]. ++ ++
Constraints:
+ ++
+ +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +- +
1 <= nums.length <= 1000- +
-105 <= nums[i] <= 105- +
1 <= k <= nums.length++ +Hint 1
+From a greedy perspective, what k elements should you pick? ++diff --git a/problems/find-substring-with-given-hash-value/README.md b/problems/find-substring-with-given-hash-value/README.md new file mode 100644 index 000000000..0c9182b7e --- /dev/null +++ b/problems/find-substring-with-given-hash-value/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../all-divisions-with-the-highest-score-of-a-binary-array "All Divisions With the Highest Score of a Binary Array") + +[Next >](../groups-of-strings "Groups of Strings") + +## [2156. Find Substring With Given Hash Value (Medium)](https://leetcode.com/problems/find-substring-with-given-hash-value "查找给定哈希值的子串") + +Hint 2
+Could you sort the array while maintaining the index? +The hash of a 0-indexed string
+ +sof lengthk, given integerspandm, is computed using the following function:+
+ +- +
hash(s, p, m) = (val(s[0]) * p0 + val(s[1]) * p1 + ... + val(s[k-1]) * pk-1) mod m.Where
+ +val(s[i])represents the index ofs[i]in the alphabet fromval('a') = 1toval('z') = 26.You are given a string
+ +sand the integerspower,modulo,k, andhashValue.Returnsub, the first substring ofsof lengthksuch thathash(sub, power, modulo) == hashValue.The test cases will be generated such that an answer always exists.
+ +A substring is a contiguous non-empty sequence of characters within a string.
+ ++
Example 1:
+ ++Input: s = "leetcode", power = 7, modulo = 20, k = 2, hashValue = 0 +Output: "ee" +Explanation: The hash of "ee" can be computed to be hash("ee", 7, 20) = (5 * 1 + 5 * 7) mod 20 = 40 mod 20 = 0. +"ee" is the first substring of length 2 with hashValue 0. Hence, we return "ee". ++ +Example 2:
+ ++Input: s = "fbxzaad", power = 31, modulo = 100, k = 3, hashValue = 32 +Output: "fbx" +Explanation: The hash of "fbx" can be computed to be hash("fbx", 31, 100) = (6 * 1 + 2 * 31 + 24 * 312) mod 100 = 23132 mod 100 = 32. +The hash of "bxz" can be computed to be hash("bxz", 31, 100) = (2 * 1 + 24 * 31 + 26 * 312) mod 100 = 25732 mod 100 = 32. +"fbx" is the first substring of length 3 with hashValue 32. Hence, we return "fbx". +Note that "bxz" also has a hash of 32 but it appears later than "fbx". ++ ++
Constraints:
+ ++
+ +### Related Topics + [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] + +### Hints +- +
1 <= k <= s.length <= 2 * 104- +
1 <= power, modulo <= 109- +
0 <= hashValue < modulo- +
sconsists of lowercase English letters only.- The test cases are generated such that an answer always exists.
+++ +Hint 1
+How can we update the hash value efficiently while iterating instead of recalculating it each time? ++diff --git a/problems/find-target-indices-after-sorting-array/README.md b/problems/find-target-indices-after-sorting-array/README.md new file mode 100644 index 000000000..ef7f2708f --- /dev/null +++ b/problems/find-target-indices-after-sorting-array/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../count-fertile-pyramids-in-a-land "Count Fertile Pyramids in a Land") + +[Next >](../k-radius-subarray-averages "K Radius Subarray Averages") + +## [2089. Find Target Indices After Sorting Array (Easy)](https://leetcode.com/problems/find-target-indices-after-sorting-array "找出数组排序后的目标下标") + +Hint 2
+Use the rolling hash method. +You are given a 0-indexed integer array
+ +numsand a target elementtarget.A target index is an index
+ +isuch thatnums[i] == target.Return a list of the target indices of
+ +numsafter sortingnumsin non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order.+
Example 1:
+ ++Input: nums = [1,2,5,2,3], target = 2 +Output: [1,2] +Explanation: After sorting, nums is [1,2,2,3,5]. +The indices where nums[i] == 2 are 1 and 2. ++ +Example 2:
+ ++Input: nums = [1,2,5,2,3], target = 3 +Output: [3] +Explanation: After sorting, nums is [1,2,2,3,5]. +The index where nums[i] == 3 is 3. ++ +Example 3:
+ ++Input: nums = [1,2,5,2,3], target = 5 +Output: [4] +Explanation: After sorting, nums is [1,2,2,3,5]. +The index where nums[i] == 5 is 4. ++ ++
Constraints:
+ ++
+ +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +- +
1 <= nums.length <= 100- +
1 <= nums[i], target <= 100++ +Hint 1
+Try "sorting" the array first. ++diff --git a/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md index 8a56a7c1b..fe8cd7fdf 100644 --- a/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md +++ b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../filter-restaurants-by-vegan-friendly-price-and-distance "Filter Restaurants by Vegan-Friendly, Price and Distance") @@ -60,10 +60,13 @@ The city 0 has 1 neighboring city at a distanceThreshold = 2. ### Related Topics - [[Graph](../../tag/graph/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Graph](../../tag/graph/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] +### Similar Questions + 1. [Second Minimum Time to Reach Destination](../second-minimum-time-to-reach-destination) (Hard) + ### HintsHint 2
+Now find all indices in the array whose values are equal to target. +Hint 1
diff --git a/problems/find-the-index-of-the-large-integer/README.md b/problems/find-the-index-of-the-large-integer/README.md index 57eb5c872..4206c138e 100644 --- a/problems/find-the-index-of-the-large-integer/README.md +++ b/problems/find-the-index-of-the-large-integer/README.md @@ -18,9 +18,6 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Interactive](../../tag/interactive/README.md)] -### Similar Questions - 1. [Search in a Sorted Array of Unknown Size](../search-in-a-sorted-array-of-unknown-size) (Medium) - ### HintsHint 1
diff --git a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md index f115bd5f2..04ac15592 100644 --- a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md +++ b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit") @@ -11,9 +11,11 @@ ## [1439. Find the Kth Smallest Sum of a Matrix With Sorted Rows (Hard)](https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "有序矩阵中的第 k 个最小数组和") -You are given an
+m * nmatrix,mat, and an integerk, which has its rows sorted in non-decreasing order.You are given an
-m x nmatrixmatthat has its rows sorted in non-decreasing order and an integerk.You are allowed to choose exactly 1 element from each row to form an array. Return the Kth smallest array sum among all possible arrays.
+You are allowed to choose exactly one element from each row to form an array.
+ +Return the
kthsmallest array sum among all possible arrays.
Example 1:
@@ -21,8 +23,9 @@Input: mat = [[1,3,11],[2,4,6]], k = 5 Output: 7 -Explanation: Choosing one element from each row, the first k smallest sum are: -[1,2], [1,4], [3,2], [3,4], [1,6]. Where the 5th sum is 7.+Explanation: Choosing one element from each row, the first k smallest sum are: +[1,2], [1,4], [3,2], [3,4], [1,6]. Where the 5th sum is 7. +Example 2:
@@ -40,13 +43,6 @@ [1,1,2], [1,1,3], [1,4,2], [1,4,3], [1,1,6], [1,5,2], [1,5,3]. Where the 7th sum is 9.
Example 4:
- --Input: mat = [[1,1,10],[2,2,9]], k = 7 -Output: 12 --
Constraints:
@@ -54,16 +50,16 @@m == mat.lengthn == mat.length[i]1 <= m, n <= 401 <= k <= min(200, n ^ m)1 <= mat[i][j] <= 5000mat[i] is a non decreasing array.1 <= k <= min(200, nm)mat[i] is a non-decreasing array.Input: nums = [2,3,-1,8,4] Output: 3 -Explanation: -The sum of the numbers before index 3 is: 2 + 3 + -1 = 4 +Explanation: The sum of the numbers before index 3 is: 2 + 3 + -1 = 4 The sum of the numbers after index 3 is: 4 = 4@@ -35,8 +34,7 @@ The sum of the numbers after index 3 is: 4 = 4
Input: nums = [1,-1,4] Output: 2 -Explanation: -The sum of the numbers before index 2 is: 1 + -1 = 0 +Explanation: The sum of the numbers before index 2 is: 1 + -1 = 0 The sum of the numbers after index 2 is: 0@@ -45,18 +43,7 @@ The sum of the numbers after index 2 is: 0
Input: nums = [2,5] Output: -1 -Explanation: -There is no valid middleIndex. -- -
Example 4:
- --Input: nums = [1] -Output: 0 -Explantion: -The sum of the numbers before index 0 is: 0 -The sum of the numbers after index 0 is: 0 +Explanation: There is no valid middleIndex.
diff --git a/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md b/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md index aa3940150..e614c8384 100644 --- a/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md +++ b/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md @@ -56,14 +56,6 @@ Thus, minDistance and maxDistance is 5 - 2 = 3. Note that the last node is not considered a local maxima because it does not have a next node. -
Example 4:
-
--Input: head = [2,3,3,2] -Output: [-1,-1] -Explanation: There are no critical points in [2,3,3,2]. --
Constraints:
diff --git a/problems/find-the-missing-ids/README.md b/problems/find-the-missing-ids/README.md index 493874513..ad3d152ac 100644 --- a/problems/find-the-missing-ids/README.md +++ b/problems/find-the-missing-ids/README.md @@ -15,3 +15,8 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Report Contiguous Dates](../report-contiguous-dates) (Hard) + 1. [Find the Start and End Number of Continuous Ranges](../find-the-start-and-end-number-of-continuous-ranges) (Medium) + 1. [Number of Transactions per Visit](../number-of-transactions-per-visit) (Hard) diff --git a/problems/find-the-most-competitive-subsequence/README.md b/problems/find-the-most-competitive-subsequence/README.md index 918cfd3ad..6f21e4840 100644 --- a/problems/find-the-most-competitive-subsequence/README.md +++ b/problems/find-the-most-competitive-subsequence/README.md @@ -43,15 +43,11 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] -### Similar Questions - 1. [Remove K Digits](../remove-k-digits) (Medium) - 1. [Smallest Subsequence of Distinct Characters](../smallest-subsequence-of-distinct-characters) (Medium) - ### HintsEach result of the division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5).
It is guaranteed that there will be an answer.
+The test cases are generated so that there will be an answer.
Example 1:
@@ -34,20 +34,6 @@ If the divisor is 4 we can get a sum of 7 (1+1+2+3) and if the divisor is 5 the Output: 44 -Example 3:
- --Input: nums = [21212,10101,12121], threshold = 1000000 -Output: 1 -- -
Example 4:
- --Input: nums = [2,3,5,7,11], threshold = 11 -Output: 3 --
Constraints:
diff --git a/problems/find-the-winner-of-an-array-game/README.md b/problems/find-the-winner-of-an-array-game/README.md index ab1c0c3a7..70bb38ceb 100644 --- a/problems/find-the-winner-of-an-array-game/README.md +++ b/problems/find-the-winner-of-an-array-game/README.md @@ -13,7 +13,7 @@Given an integer array arr of distinct integers and an integer k.
A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0 and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.
A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0, and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.
Return the integer which will win the game.
@@ -42,20 +42,6 @@ So we can see that 4 rounds will be played and 5 is the winner because it wins 2 Explanation: 3 will win the first 10 rounds consecutively. -Example 3:
- --Input: arr = [1,9,8,2,3,7,6,4,5], k = 7 -Output: 9 -- -
Example 4:
- --Input: arr = [1,11,22,33,44,55,66,77,88,99], k = 1000000000 -Output: 99 --
Constraints:
diff --git a/problems/find-the-winner-of-the-circular-game/README.md b/problems/find-the-winner-of-the-circular-game/README.md index 72592a8ab..f697c1c36 100644 --- a/problems/find-the-winner-of-the-circular-game/README.md +++ b/problems/find-the-winner-of-the-circular-game/README.md @@ -58,9 +58,10 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Queue](../../tag/queue/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md index 028421234..8f35b94cf 100644 --- a/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md +++ b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subrectangle-queries "Subrectangle Queries") @@ -11,7 +11,7 @@ ## [1477. Find Two Non-overlapping Sub-arrays Each With Target Sum (Medium)](https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum "找两个和为目标值且不重叠的子数组") -Given an array of integers arr and an integer target.
You are given an array of integers arr and an integer target.
You have to find two non-overlapping sub-arrays of arr each with a sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.
Example 4:
- --Input: arr = [5,5,4,4,5], target = 3 -Output: -1 -Explanation: We cannot find a sub-array of sum = 3. -- -
Example 5:
- --Input: arr = [3,1,1,1,5,1,2,1], target = 3 -Output: 3 -Explanation: Note that sub-arrays [1,2] and [2,1] cannot be an answer because they overlap. --
Constraints:
diff --git a/problems/find-valid-matrix-given-row-and-column-sums/README.md b/problems/find-valid-matrix-given-row-and-column-sums/README.md index 937b21680..1ca194f17 100644 --- a/problems/find-valid-matrix-given-row-and-column-sums/README.md +++ b/problems/find-valid-matrix-given-row-and-column-sums/README.md @@ -24,11 +24,11 @@ Input: rowSum = [3,8], colSum = [4,7] Output: [[3,0], [1,7]] -Explanation: -0th row: 3 + 0 = 3 == rowSum[0] -1st row: 1 + 7 = 8 == rowSum[1] -0th column: 3 + 1 = 4 == colSum[0] -1st column: 0 + 7 = 7 == colSum[1] +Explanation: +0th row: 3 + 0 = 3 == rowSum[0] +1st row: 1 + 7 = 8 == rowSum[1] +0th column: 3 + 1 = 4 == colSum[0] +1st column: 0 + 7 = 7 == colSum[1] The row and column sums match, and all matrix elements are non-negative. Another possible matrix is: [[1,2], [3,5]] @@ -43,29 +43,6 @@ Another possible matrix is: [[1,2], [2,0,8]] -Example 3:
- --Input: rowSum = [14,9], colSum = [6,9,8] -Output: [[0,9,5], - [6,0,3]] -- -
Example 4:
- --Input: rowSum = [1,0], colSum = [1] -Output: [[1], - [0]] -- -
Example 5:
- --Input: rowSum = [0], colSum = [0] -Output: [[0]] --
Constraints:
diff --git a/problems/find-winner-on-a-tic-tac-toe-game/README.md b/problems/find-winner-on-a-tic-tac-toe-game/README.md index a9fb045d4..b92f461f3 100644 --- a/problems/find-winner-on-a-tic-tac-toe-game/README.md +++ b/problems/find-winner-on-a-tic-tac-toe-game/README.md @@ -51,14 +51,6 @@ Explanation: The game ends in a draw since there are no moves to make. -Example 4:
-
--Input: moves = [[0,0],[1,1]] -Output: "Pending" -Explanation: The game has not finished yet. --
Constraints:
diff --git a/problems/finding-3-digit-even-numbers/README.md b/problems/finding-3-digit-even-numbers/README.md new file mode 100644 index 000000000..b3b7cc928 --- /dev/null +++ b/problems/finding-3-digit-even-numbers/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../minimum-cost-to-reach-city-with-discounts "Minimum Cost to Reach City With Discounts") + +[Next >](../delete-the-middle-node-of-a-linked-list "Delete the Middle Node of a Linked List") + +## [2094. Finding 3-Digit Even Numbers (Easy)](https://leetcode.com/problems/finding-3-digit-even-numbers "找出 3 位偶数") + +You are given an integer array digits, where each element is a digit. The array may contain duplicates.
You need to find all the unique integers that follow the given requirements:
+ +digits in any arbitrary order.For example, if the given digits were [1, 2, 3], integers 132 and 312 follow the requirements.
Return a sorted array of the unique integers.
+ ++
Example 1:
+ ++Input: digits = [2,1,3,0] +Output: [102,120,130,132,210,230,302,310,312,320] +Explanation: All the possible integers that follow the requirements are in the output array. +Notice that there are no odd integers or integers with leading zeros. ++ +
Example 2:
+ ++Input: digits = [2,2,8,8,2] +Output: [222,228,282,288,822,828,882] +Explanation: The same digit can be used as many times as it appears in digits. +In this example, the digit 8 is used twice each time in 288, 828, and 882. ++ +
Example 3:
+ ++Input: digits = [3,7,5] +Output: [] +Explanation: No even integers can be formed using the given digits. ++ +
+
Constraints:
+ +3 <= digits.length <= 1000 <= digits[i] <= 9Given an array of integers cost and an integer target. Return the maximum integer you can paint under the following rules:
Given an array of integers cost and an integer target, return the maximum integer you can paint under the following rules:
cost[i] (0 indexed).target.(i + 1) is given by cost[i] (0-indexed).target.0 digits.Since the answer may be too large, return it as string.
- -If there is no way to paint any integer given the condition, return "0".
+Since the answer may be very large, return it as a string. If there is no way to paint any integer given the condition, return "0".
Example 1:
@@ -29,7 +27,7 @@
Input: cost = [4,3,2,5,6,7,2,5,5], target = 9
Output: "7772"
-Explanation: The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost("7772") = 2*3+ 3*1 = 9. You could also paint "977", but "7772" is the largest number.
+Explanation: The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost("7772") = 2*3+ 3*1 = 9. You could also paint "977", but "7772" is the largest number.
Digit cost
1 -> 4
2 -> 3
@@ -55,14 +53,7 @@
Input: cost = [2,4,6,2,4,6,4,4,4], target = 5
Output: "0"
-Explanation: It's not possible to paint any integer with total cost equal to target.
-
-
-Example 4:
-
-
-Input: cost = [6,10,15,40,40,40,40,40,40], target = 47
-Output: "32211"
+Explanation: It is impossible to paint any integer with total cost equal to target.
@@ -70,8 +61,7 @@
cost.length == 91 <= cost[i] <= 50001 <= target <= 50001 <= cost[i], target <= 5000The edges of the undirected tree are given in the array edges, where edges[i] = [ai, bi] means that exists an edge connecting the vertices ai and bi.
Return the probability that after t seconds the frog is on the vertex target.
Return the probability that after t seconds the frog is on the vertex target. Answers within 10-5 of the actual answer will be accepted.
Example 1:
- -
Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 2, target = 4 Output: 0.16666666666666666 -Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 probability to the vertex 2 after second 1 and then jumping with 1/2 probability to vertex 4 after second 2. Thus the probability for the frog is on the vertex 4 after 2 seconds is 1/3 * 1/2 = 1/6 = 0.16666666666666666. +Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 probability to the vertex 2 after second 1 and then jumping with 1/2 probability to vertex 4 after second 2. Thus the probability for the frog is on the vertex 4 after 2 seconds is 1/3 * 1/2 = 1/6 = 0.16666666666666666.
Example 2:
- -
Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 1, target = 7 @@ -38,13 +35,6 @@ Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 = 0.3333333333333333 probability to the vertex 7 after second 1.-
Example 3:
- --Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 20, target = 6 -Output: 0.16666666666666666 --
Constraints:
@@ -53,9 +43,8 @@edges.length == n - 1edges[i].length == 21 <= ai, bi <= n1 <= t <= 501 <= target <= n10-5 of the actual value will be accepted as correct.1 <= t <= 501 <= target <= nExample 4:
- --Input: fruits = [3,3,3,1,2,1,1,2,3,3,4] -Output: 5 -Explanation: We can pick from trees [1,2,1,1,2]. --
Constraints:
diff --git a/problems/game-play-analysis-i/README.md b/problems/game-play-analysis-i/README.md index eaa4b32f3..5fccd1c99 100644 --- a/problems/game-play-analysis-i/README.md +++ b/problems/game-play-analysis-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../inorder-successor-in-bst-ii "Inorder Successor in BST II") diff --git a/problems/get-the-maximum-score/README.md b/problems/get-the-maximum-score/README.md index 86d638303..26e258cc6 100644 --- a/problems/get-the-maximum-score/README.md +++ b/problems/get-the-maximum-score/README.md @@ -27,13 +27,11 @@
Example 1:
- -
Input: nums1 = [2,4,5,8,10], nums2 = [4,6,8,9] Output: 30 -Explanation: Valid paths: +Explanation: Valid paths: [2,4,5,8,10], [2,4,5,8,9], [2,4,6,8,9], [2,4,6,8,10], (starting from nums1) [4,6,8,9], [4,5,8,10], [4,5,8,9], [4,6,8,10] (starting from nums2) The maximum is obtained with the path in green [2,4,6,8,10]. @@ -44,7 +42,7 @@ The maximum is obtained with the path in green [2,4,6,8,10].-Input: nums1 = [1,3,5,7,9], nums2 = [3,5,100] Output: 109 -Explanation: Maximum sum is obtained with the path [1,3,5,100]. +Explanation: Maximum sum is obtained with the path [1,3,5,100].Example 3:
@@ -52,17 +50,10 @@ The maximum is obtained with the path in green [2,4,6,8,10].Input: nums1 = [1,2,3,4,5], nums2 = [6,7,8,9,10] Output: 40 -Explanation: There are no common elements between nums1 and nums2. +Explanation: There are no common elements between nums1 and nums2. Maximum sum is obtained with the path [6,7,8,9,10].-Example 4:
- --Input: nums1 = [1,4,5,8,9,11,19], nums2 = [2,3,4,11,12] -Output: 61 --
Constraints:
@@ -73,10 +64,10 @@ Maximum sum is obtained with the path [6,7,8,9,10]. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hintsdiff --git a/problems/get-the-second-most-recent-activity/README.md b/problems/get-the-second-most-recent-activity/README.md index 11682b2cc..60c83d6b0 100644 --- a/problems/get-the-second-most-recent-activity/README.md +++ b/problems/get-the-second-most-recent-activity/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-make-at-least-one-valid-path-in-a-grid "Minimum Cost to Make at Least One Valid Path in a Grid") diff --git a/problems/group-employees-of-the-same-salary/README.md b/problems/group-employees-of-the-same-salary/README.md index f221375de..0b2f7fc0a 100644 --- a/problems/group-employees-of-the-same-salary/README.md +++ b/problems/group-employees-of-the-same-salary/README.md @@ -9,7 +9,7 @@ [Next >](../substrings-of-size-three-with-distinct-characters "Substrings of Size Three with Distinct Characters") -## [1875. Group Employees of the Same Salary (Medium)](https://leetcode.com/problems/group-employees-of-the-same-salary "") +## [1875. Group Employees of the Same Salary (Medium)](https://leetcode.com/problems/group-employees-of-the-same-salary "将工资相同的雇员分组") diff --git a/problems/group-sold-products-by-the-date/README.md b/problems/group-sold-products-by-the-date/README.md index f107e9cdc..6722eb2d8 100644 --- a/problems/group-sold-products-by-the-date/README.md +++ b/problems/group-sold-products-by-the-date/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-ancestor-of-a-tree-node "Kth Ancestor of a Tree Node") diff --git a/problems/groups-of-strings/README.md b/problems/groups-of-strings/README.md new file mode 100644 index 000000000..0cc7e7afb --- /dev/null +++ b/problems/groups-of-strings/README.md @@ -0,0 +1,96 @@ + + + + + + + +[< Previous](../find-substring-with-given-hash-value "Find Substring With Given Hash Value") + +[Next >](../amount-of-new-area-painted-each-day "Amount of New Area Painted Each Day") + +## [2157. Groups of Strings (Hard)](https://leetcode.com/problems/groups-of-strings "字符串分组") + +You are given a 0-indexed array of strings
+ +words. Each string consists of lowercase English letters only. No letter occurs more than once in any string ofwords.Two strings
+ +s1ands2are said to be connected if the set of letters ofs2can be obtained from the set of letters ofs1by any one of the following operations:+
+ +- Adding exactly one letter to the set of the letters of
+s1.- Deleting exactly one letter from the set of the letters of
+s1.- Replacing exactly one letter from the set of the letters of
+s1with any letter, including itself.The array
+ +wordscan be divided into one or more non-intersecting groups. A string belongs to a group if any one of the following is true:+
+ +- It is connected to at least one other string of the group.
+- It is the only string present in the group.
+Note that the strings in
+ +wordsshould be grouped in such a manner that a string belonging to a group cannot be connected to a string present in any other group. It can be proved that such an arrangement is always unique.Return an array
+ +ansof size2where:+
+ +- +
ans[0]is the maximum number of groupswordscan be divided into, and- +
ans[1]is the size of the largest group.+
Example 1:
+ ++Input: words = ["a","b","ab","cde"] +Output: [2,3] +Explanation: +- words[0] can be used to obtain words[1] (by replacing 'a' with 'b'), and words[2] (by adding 'b'). So words[0] is connected to words[1] and words[2]. +- words[1] can be used to obtain words[0] (by replacing 'b' with 'a'), and words[2] (by adding 'a'). So words[1] is connected to words[0] and words[2]. +- words[2] can be used to obtain words[0] (by deleting 'b'), and words[1] (by deleting 'a'). So words[2] is connected to words[0] and words[1]. +- words[3] is not connected to any string in words. +Thus, words can be divided into 2 groups ["a","b","ab"] and ["cde"]. The size of the largest group is 3. ++ +Example 2:
+ ++Input: words = ["a","ab","abc"] +Output: [1,3] +Explanation: +- words[0] is connected to words[1]. +- words[1] is connected to words[0] and words[2]. +- words[2] is connected to words[1]. +Since all strings are connected to each other, they should be grouped together. +Thus, the size of the largest group is 3. ++ ++
Constraints:
+ ++
+ +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +- +
1 <= words.length <= 2 * 104- +
1 <= words[i].length <= 26- +
words[i]consists of lowercase English letters only.- No letter occurs more than once in
+words[i].++ +Hint 1
+Can we build a graph from words, where there exists an edge between nodes i and j if words[i] and words[j] are connected? +++ +Hint 2
+The problem now boils down to finding the total number of components and the size of the largest component in the graph. ++diff --git a/problems/guess-number-higher-or-lower/README.md b/problems/guess-number-higher-or-lower/README.md index c09647967..52aa4fcb3 100644 --- a/problems/guess-number-higher-or-lower/README.md +++ b/problems/guess-number-higher-or-lower/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-k-pairs-with-smallest-sums "Find K Pairs with Smallest Sums") @@ -17,30 +17,38 @@Hint 3
+How can we use bit masking to reduce the search space while adding edges to node i? +Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess.
-You call a pre-defined API
+int guess(int num), which returns 3 possible results:You call a pre-defined API
int guess(int num), which returns three possible results:-
- -
-1: The number I picked is lower than your guess (i.e.pick < num).- -
1: The number I picked is higher than your guess (i.e.pick > num).- +
0: The number I picked is equal to your guess (i.e.pick == num).- +
-1: Your guess is higher than the number I picked (i.e.num > pick).- +
1: Your guess is lower than the number I picked (i.e.num < pick).0: your guess is equal to the number I picked (i.e.num == pick).Return the number that I picked.
Example 1:
-Input: n = 10, pick = 6 + ++Input: n = 10, pick = 6 Output: 6 -Example 2:
-Input: n = 1, pick = 1 ++ +Example 2:
+ ++Input: n = 1, pick = 1 Output: 1 -Example 3:
-Input: n = 2, pick = 1 ++ +Example 3:
+ ++Input: n = 2, pick = 1 Output: 1 -Example 4:
-Input: n = 2, pick = 2 -Output: 2+
Constraints:
diff --git a/problems/guess-the-word/README.md b/problems/guess-the-word/README.md index 488ba5ca4..97fb5c1ad 100644 --- a/problems/guess-the-word/README.md +++ b/problems/guess-the-word/README.md @@ -59,5 +59,5 @@ We made 5 calls to master.guess and one of them was the secret, so we pass the t [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] - [[Interactive](../../tag/interactive/README.md)] [[Game Theory](../../tag/game-theory/README.md)] + [[Interactive](../../tag/interactive/README.md)] diff --git a/problems/hexspeak/README.md b/problems/hexspeak/README.md index 9813d663b..a1b971d22 100644 --- a/problems/hexspeak/README.md +++ b/problems/hexspeak/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-people-report-to-the-given-manager "All People Report to the Given Manager") diff --git a/problems/hopper-company-queries-i/README.md b/problems/hopper-company-queries-i/README.md index da53acdea..c436e61f3 100644 --- a/problems/hopper-company-queries-i/README.md +++ b/problems/hopper-company-queries-i/README.md @@ -15,8 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Trips and Users](../trips-and-users) (Hard) - 1. [Hopper Company Queries II](../hopper-company-queries-ii) (Hard) - 1. [Hopper Company Queries III](../hopper-company-queries-iii) (Hard) diff --git a/problems/hopper-company-queries-iii/README.md b/problems/hopper-company-queries-iii/README.md index 62a14af70..5424cf7fb 100644 --- a/problems/hopper-company-queries-iii/README.md +++ b/problems/hopper-company-queries-iii/README.md @@ -15,8 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Trips and Users](../trips-and-users) (Hard) - 1. [Hopper Company Queries I](../hopper-company-queries-i) (Hard) - 1. [Hopper Company Queries II](../hopper-company-queries-ii) (Hard) diff --git a/problems/house-robber-iii/README.md b/problems/house-robber-iii/README.md index 4f3e1613f..350409147 100644 --- a/problems/house-robber-iii/README.md +++ b/problems/house-robber-iii/README.md @@ -43,9 +43,9 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/house-robber/README.md b/problems/house-robber/README.md index 572ab037c..a37cd0a07 100644 --- a/problems/house-robber/README.md +++ b/problems/house-robber/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rising-temperature "Rising Temperature") diff --git a/problems/how-many-numbers-are-smaller-than-the-current-number/README.md b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md index 1418fd842..2b291471d 100644 --- a/problems/how-many-numbers-are-smaller-than-the-current-number/README.md +++ b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-trusted-contacts-of-a-customer "Number of Trusted Contacts of a Customer") diff --git a/problems/html-entity-parser/README.md b/problems/html-entity-parser/README.md index 87d42149e..5201de90f 100644 --- a/problems/html-entity-parser/README.md +++ b/problems/html-entity-parser/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../queries-on-a-permutation-with-key "Queries on a Permutation With Key") @@ -16,17 +16,17 @@The special characters and their entities for HTML are:
-
- Quotation Mark: the entity is
-"and symbol character is".- Single Quote Mark: the entity is
-'and symbol character is'.- Ampersand: the entity is
-&and symbol character is&.- Greater Than Sign: the entity is
->and symbol character is>.- Less Than Sign: the entity is
-<and symbol character is<.- Slash: the entity is
+⁄and symbol character is/.- Quotation Mark: the entity is
+"and symbol character is".- Single Quote Mark: the entity is
+'and symbol character is'.- Ampersand: the entity is
+&and symbol character is&.- Greater Than Sign: the entity is
+>and symbol character is>.- Less Than Sign: the entity is
+<and symbol character is<.- Slash: the entity is
⁄and symbol character is/.Given the input
-textstring to the HTML parser, you have to implement the entity parser.Return the text after replacing the entities by the special characters.
+Return the text after replacing the entities by the special characters.
Example 1:
@@ -44,33 +44,12 @@ Output: "and I quote: \"...\""
Example 3:
- --Input: text = "Stay home! Practice on Leetcode :)" -Output: "Stay home! Practice on Leetcode :)" -- -
Example 4:
- --Input: text = "x > y && x < y is always false" -Output: "x > y && x < y is always false" -- -
Example 5:
- --Input: text = "leetcode.com⁄problemset⁄all" -Output: "leetcode.com/problemset/all" --
Constraints:
1 <= text.length <= 10^51 <= text.length <= 105Given a string s. You should re-order the string using the following algorithm:
You are given a string s. Reorder the string using the following algorithm:
s and append it to the result.s which is greater than the last appended character to the result and append it.s and append it to the result.s which is smaller than the last appended character to the result and append it.s and append it to the result.s which is smaller than the last appended character to the result and append it.s.In each step, If the smallest or the largest character appears more than once you can choose any occurrence and append it to the result.
-Return the result string after sorting s with this algorithm.
Return the result string after sorting s with this algorithm.
Example 1:
@@ -48,33 +48,12 @@ After steps 4, 5 and 6 of the second iteration, result = "abccbaabccba" Explanation: The word "rat" becomes "art" after re-ordering it with the mentioned algorithm. -Example 3:
- --Input: s = "leetcode" -Output: "cdelotee" -- -
Example 4:
- --Input: s = "ggggggg" -Output: "ggggggg" -- -
Example 5:
- --Input: s = "spo" -Output: "ops" --
Constraints:
1 <= s.length <= 500s contains only lower-case English letters.s consists of only lowercase English letters.
Example 1:
-Input: num = 123 -Output: "One Hundred Twenty Three" -
Example 2:
-Input: num = 12345 -Output: "Twelve Thousand Three Hundred Forty Five" -
Example 3:
-Input: num = 1234567 -Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven" -
Example 4:
-Input: num = 1234567891 -Output: "One Billion Two Hundred Thirty Four Million Five Hundred Sixty Seven Thousand Eight Hundred Ninety One" + ++Input: num = 123 +Output: "One Hundred Twenty Three" ++ +Example 2:
+ ++Input: num = 12345 +Output: "Twelve Thousand Three Hundred Forty Five"+ +Example 3:
+ ++Input: num = 1234567 +Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven" ++
Constraints:
diff --git a/problems/intervals-between-identical-elements/README.md b/problems/intervals-between-identical-elements/README.md new file mode 100644 index 000000000..8b689aeac --- /dev/null +++ b/problems/intervals-between-identical-elements/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../execution-of-all-suffix-instructions-staying-in-a-grid "Execution of All Suffix Instructions Staying in a Grid") + +[Next >](../recover-the-original-array "Recover the Original Array") + +## [2121. Intervals Between Identical Elements (Medium)](https://leetcode.com/problems/intervals-between-identical-elements "相同元素的间隔之和") + +You are given a 0-indexed array of
+ +nintegersarr.The interval between two elements in
+ +arris defined as the absolute difference between their indices. More formally, the interval betweenarr[i]andarr[j]is|i - j|.Return an array
+ +intervalsof lengthnwhereintervals[i]is the sum of intervals betweenarr[i]and each element inarrwith the same value asarr[i].Note:
+ +|x|is the absolute value ofx.+
Example 1:
+ ++Input: arr = [2,1,3,1,2,3,3] +Output: [4,2,7,2,4,4,5] +Explanation: +- Index 0: Another 2 is found at index 4. |0 - 4| = 4 +- Index 1: Another 1 is found at index 3. |1 - 3| = 2 +- Index 2: Two more 3s are found at indices 5 and 6. |2 - 5| + |2 - 6| = 7 +- Index 3: Another 1 is found at index 1. |3 - 1| = 2 +- Index 4: Another 2 is found at index 0. |4 - 0| = 4 +- Index 5: Two more 3s are found at indices 2 and 6. |5 - 2| + |5 - 6| = 4 +- Index 6: Two more 3s are found at indices 2 and 5. |6 - 2| + |6 - 5| = 5 ++ +Example 2:
+ ++Input: arr = [10,5,10,10] +Output: [5,0,3,4] +Explanation: +- Index 0: Two more 10s are found at indices 2 and 3. |0 - 2| + |0 - 3| = 5 +- Index 1: There is only one 5 in the array, so its sum of intervals to identical elements is 0. +- Index 2: Two more 10s are found at indices 0 and 3. |2 - 0| + |2 - 3| = 3 +- Index 3: Two more 10s are found at indices 0 and 2. |3 - 0| + |3 - 2| = 4 ++ ++
Constraints:
+ +
n == arr.length1 <= n <= 1051 <= arr[i] <= 105Example 4:
- --Input: arr = [7,1,7,1,7,1], d = 2 -Output: 2 -- -
Example 5:
- --Input: arr = [66], d = 1 -Output: 1 --
Constraints:
1 <= arr.length <= 10001 <= arr[i] <= 10^51 <= arr[i] <= 1051 <= d <= arr.lengthYou are given a 0-indexed 2D integer array grid of size m x n that represents a map of the items in a shop. The integers in the grid represent the following:
0 represents a wall that you cannot pass through.1 represents an empty cell that you can freely move to and from.It takes 1 step to travel between adjacent grid cells.
You are also given integer arrays pricing and start where pricing = [low, high] and start = [row, col] indicates that you start at the position (row, col) and are interested only in items with a price in the range of [low, high] (inclusive). You are further given an integer k.
You are interested in the positions of the k highest-ranked items whose prices are within the given price range. The rank is determined by the first of these criteria that is different:
start (shorter distance has a higher rank).Return the k highest-ranked items within the price range sorted by their rank (highest to lowest). If there are fewer than k reachable items within the price range, return all of them.
+
Example 1:
+
++Input: grid = [[1,2,0,1],[1,3,0,1],[0,2,5,1]], pricing = [2,5], start = [0,0], k = 3 +Output: [[0,1],[1,1],[2,1]] +Explanation: You start at (0,0). +With a price range of [2,5], we can take items from (0,1), (1,1), (2,1) and (2,2). +The ranks of these items are: +- (0,1) with distance 1 +- (1,1) with distance 2 +- (2,1) with distance 3 +- (2,2) with distance 4 +Thus, the 3 highest ranked items in the price range are (0,1), (1,1), and (2,1). ++ +
Example 2:
+
++Input: grid = [[1,2,0,1],[1,3,3,1],[0,2,5,1]], pricing = [2,3], start = [2,3], k = 2 +Output: [[2,1],[1,2]] +Explanation: You start at (2,3). +With a price range of [2,3], we can take items from (0,1), (1,1), (1,2) and (2,1). +The ranks of these items are: +- (2,1) with distance 2, price 2 +- (1,2) with distance 2, price 3 +- (1,1) with distance 3 +- (0,1) with distance 4 +Thus, the 2 highest ranked items in the price range are (2,1) and (1,2). ++ +
Example 3:
+
++Input: grid = [[1,1,1],[0,0,1],[2,3,4]], pricing = [2,3], start = [0,0], k = 3 +Output: [[2,1],[2,0]] +Explanation: You start at (0,0). +With a price range of [2,3], we can take items from (2,0) and (2,1). +The ranks of these items are: +- (2,1) with distance 5 +- (2,0) with distance 6 +Thus, the 2 highest ranked items in the price range are (2,1) and (2,0). +Note that k = 3 but there are only 2 reachable items within the price range. ++ +
+
Constraints:
+ +m == grid.lengthn == grid[i].length1 <= m, n <= 1051 <= m * n <= 1050 <= grid[i][j] <= 105pricing.length == 22 <= low <= high <= 105start.length == 20 <= row <= m - 10 <= col <= n - 1grid[row][col] > 01 <= k <= m * nYou are given a 0-indexed array nums of n integers, and an integer k.
The k-radius average for a subarray of nums centered at some index i with the radius k is the average of all elements in nums between the indices i - k and i + k (inclusive). If there are less than k elements before or after the index i, then the k-radius average is -1.
Build and return an array avgs of length n where avgs[i] is the k-radius average for the subarray centered at index i.
The average of x elements is the sum of the x elements divided by x, using integer division. The integer division truncates toward zero, which means losing its fractional part.
2, 3, 1, and 5 is (2 + 3 + 1 + 5) / 4 = 11 / 4 = 2.75, which truncates to 2.+
Example 1:
+
++Input: nums = [7,4,3,9,1,8,5,2,6], k = 3 +Output: [-1,-1,-1,5,4,4,-1,-1,-1] +Explanation: +- avg[0], avg[1], and avg[2] are -1 because there are less than k elements before each index. +- The sum of the subarray centered at index 3 with radius 3 is: 7 + 4 + 3 + 9 + 1 + 8 + 5 = 37. + Using integer division, avg[3] = 37 / 7 = 5. +- For the subarray centered at index 4, avg[4] = (4 + 3 + 9 + 1 + 8 + 5 + 2) / 7 = 4. +- For the subarray centered at index 5, avg[5] = (3 + 9 + 1 + 8 + 5 + 2 + 6) / 7 = 4. +- avg[6], avg[7], and avg[8] are -1 because there are less than k elements after each index. ++ +
Example 2:
+ ++Input: nums = [100000], k = 0 +Output: [100000] +Explanation: +- The sum of the subarray centered at index 0 with radius 0 is: 100000. + avg[0] = 100000 / 1 = 100000. ++ +
Example 3:
+ ++Input: nums = [8], k = 100000 +Output: [-1] +Explanation: +- avg[0] is -1 because there are less than k elements before and after index 0. ++ +
+
Constraints:
+ +n == nums.length1 <= n <= 1050 <= nums[i], k <= 105You are given an array of integers nums. You are also given an integer original which is the first number that needs to be searched for in nums.
You then do the following steps:
+ +original is found in nums, multiply it by two (i.e., set original = 2 * original).Return the final value of original.
+
Example 1:
+ ++Input: nums = [5,3,6,1,12], original = 3 +Output: 24 +Explanation: +- 3 is found in nums. 3 is multiplied by 2 to obtain 6. +- 6 is found in nums. 6 is multiplied by 2 to obtain 12. +- 12 is found in nums. 12 is multiplied by 2 to obtain 24. +- 24 is not found in nums. Thus, 24 is returned. ++ +
Example 2:
+ ++Input: nums = [2,7,9], original = 4 +Output: 4 +Explanation: +- 4 is not found in nums. Thus, 4 is returned. ++ +
+
Constraints:
+ +1 <= nums.length <= 10001 <= nums[i], original <= 1000Example 4:
- --Input: digits = [0,0,0,0,0,0] -Output: "0" --
Constraints:
@@ -53,9 +46,9 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### HintsGiven a list of non-negative integers nums, arrange them such that they form the largest number.
Given a list of non-negative integers nums, arrange them such that they form the largest number and return it.
Note: The result may be very large, so you need to return a string instead of an integer.
+Since the result may be very large, so you need to return a string instead of an integer.
Example 1:
@@ -30,20 +30,6 @@ Output: "9534330" -Example 3:
- --Input: nums = [1] -Output: "1" -- -
Example 4:
- --Input: nums = [10] -Output: "10" --
Constraints:
diff --git a/problems/largest-odd-number-in-string/README.md b/problems/largest-odd-number-in-string/README.md index 71116c391..433ce9589 100644 --- a/problems/largest-odd-number-in-string/README.md +++ b/problems/largest-odd-number-in-string/README.md @@ -49,9 +49,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
Example 1:
-Input: nums = [2,1,2] + +-+Input: nums = [2,1,2] Output: 5 -Example 2:
-Input: nums = [1,2,1] ++ +Example 2:
+ ++Input: nums = [1,2,1] Output: 0 -Example 3:
-Input: nums = [3,2,3,4] -Output: 10 -Example 4:
-Input: nums = [3,6,2,3] -Output: 8+
Constraints:
diff --git a/problems/largest-subarray-length-k/README.md b/problems/largest-subarray-length-k/README.md index f4590c82e..29371e2c9 100644 --- a/problems/largest-subarray-length-k/README.md +++ b/problems/largest-subarray-length-k/README.md @@ -14,8 +14,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hintsdiff --git a/problems/largest-submatrix-with-rearrangements/README.md b/problems/largest-submatrix-with-rearrangements/README.md index 6c614e375..fd5ac277b 100644 --- a/problems/largest-submatrix-with-rearrangements/README.md +++ b/problems/largest-submatrix-with-rearrangements/README.md @@ -17,9 +17,7 @@
Example 1:
- -- +
Input: matrix = [[0,0,1],[1,1,1],[1,0,1]] Output: 4 @@ -28,9 +26,7 @@ The largest submatrix of 1s, in bold, has an area of 4.Example 2:
- -- +
Input: matrix = [[1,0,1,0,1]] Output: 3 @@ -43,14 +39,8 @@ The largest submatrix of 1s, in bold, has an area of 3.Input: matrix = [[1,1,0],[1,0,1]] Output: 2 -Explanation: Notice that you must rearrange entire columns, and there is no way to make a submatrix of 1s larger than an area of 2.- -Example 4:
- --Input: matrix = [[0,0],[0,0]] -Output: 0 -Explanation: As there are no 1s, no submatrix of 1s can be formed and the area is 0.+Explanation: Notice that you must rearrange entire columns, and there is no way to make a submatrix of 1s larger than an area of 2. +
Constraints:
@@ -59,7 +49,7 @@ The largest submatrix of 1s, in bold, has an area of 3.m == matrix.lengthn == matrix[i].length- 1 <= m * n <= 105+ matrix[i][j]is0or1.### Related Topics diff --git a/problems/largest-substring-between-two-equal-characters/README.md b/problems/largest-substring-between-two-equal-characters/README.md index c707c3506..46a160a10 100644 --- a/problems/largest-substring-between-two-equal-characters/README.md +++ b/problems/largest-substring-between-two-equal-characters/README.md @@ -39,14 +39,6 @@ Explanation: There are no characters that appear twice in s. matrix[i][j]is either0or1.
Example 4:
- --Input: s = "cabbac" -Output: 4 -Explanation: The optimal substring here is "abba". Other non-optimal substrings include "bb" and "". --
Constraints:
diff --git a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md index 2cd2780b0..4c259e38a 100644 --- a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md +++ b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md @@ -11,13 +11,13 @@ ## [1503. Last Moment Before All Ants Fall Out of a Plank (Medium)](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") -We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with speed 1 unit per second. Some of the ants move to the left, the other move to the right.
We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with a speed of 1 unit per second. Some of the ants move to the left, the other move to the right.
When two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions doesn't take any additional time.
+When two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions does not take any additional time.
-When an ant reaches one end of the plank at a time t, it falls out of the plank imediately.
When an ant reaches one end of the plank at a time t, it falls out of the plank immediately.
Given an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right. Return the moment when the last ant(s) fall out of the plank.
Given an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right, return the moment when the last ant(s) fall out of the plank.
Example 1:
@@ -30,7 +30,7 @@ -The ant at index 1 is named B and going to the right. -The ant at index 3 is named C and going to the left. -The ant at index 4 is named D and going to the left. -Note that the last moment when an ant was on the plank is t = 4 second, after that it falls imediately out of the plank. (i.e. We can say that at t = 4.0000000001, there is no ants on the plank). +The last moment when an ant was on the plank is t = 4 seconds. After that, it falls immediately out of the plank. (i.e., We can say that at t = 4.0000000001, there are no ants on the plank).Example 2:
@@ -49,26 +49,11 @@ Note that the last moment when an ant was on the plank is t = 4 second, after th Explanation: All ants are going to the left, the ant at index 7 needs 7 seconds to fall. -Example 4:
- --Input: n = 9, left = [5], right = [4] -Output: 5 -Explanation: At t = 1 second, both ants will be at the same intial position but with different direction. -- -
Example 5:
- --Input: n = 6, left = [6], right = [0] -Output: 6 --
Constraints:
1 <= n <= 10^41 <= n <= 1040 <= left.length <= n + 10 <= left[i] <= n0 <= right.length <= n + 1Given a string s, we can transform every letter individually to be lowercase or uppercase to create another string.
Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string.
Return a list of all possible strings we could create. You can return the output in any order.
+Return a list of all possible strings we could create. Return the output in any order.
Example 1:
@@ -30,32 +30,18 @@ Output: ["3z4","3Z4"] -Example 3:
- --Input: s = "12345" -Output: ["12345"] -- -
Example 4:
- --Input: s = "0" -Output: ["0"] --
Constraints:
s will be a string with length between 1 and 12.s will consist only of letters or digits.1 <= s.length <= 12s consists of lowercase English letters, uppercase English letters, and digits.Input: s = "5525", a = 9, b = 2 Output: "2050" -Explanation: We can apply the following operations: +Explanation: We can apply the following operations: Start: "5525" Rotate: "2555" Add: "2454" Add: "2353" Rotate: "5323" Add: "5222" -Add: "5121" -Rotate: "2151" +Add: "5121" +Rotate: "2151" Add: "2050" There is no way to obtain a string that is lexicographically smaller then "2050".@@ -48,7 +48,7 @@ There is no way to obtain a string that is lexicographically smaller then "
Input: s = "74", a = 5, b = 1 Output: "24" -Explanation: We can apply the following operations: +Explanation: We can apply the following operations: Start: "74" Rotate: "47" Add: "42" @@ -61,14 +61,7 @@ There is no way to obtain a string that is lexicographically smaller then "-Input: s = "0011", a = 4, b = 2 Output: "0011" -Explanation: There are no sequence of operations that will give us a lexicographically smaller string than "0011". -- -Example 4:
- --Input: s = "43987654", a = 7, b = 3 -Output: "00553311" +Explanation: There are no sequence of operations that will give us a lexicographically smaller string than "0011".@@ -83,8 +76,8 @@ There is no way to obtain a string that is lexicographically smaller then " ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[String](../../tag/string/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
diff --git a/problems/line-reflection/README.md b/problems/line-reflection/README.md index e102b042a..ba950f01d 100644 --- a/problems/line-reflection/README.md +++ b/problems/line-reflection/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-twitter "Design Twitter") diff --git a/problems/linked-list-in-binary-tree/README.md b/problems/linked-list-in-binary-tree/README.md index bd5ccf805..9b1a71dfe 100644 --- a/problems/linked-list-in-binary-tree/README.md +++ b/problems/linked-list-in-binary-tree/README.md @@ -55,10 +55,10 @@ ### Related Topics + [[Linked List](../../tag/linked-list/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Linked List](../../tag/linked-list/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/logger-rate-limiter/README.md b/problems/logger-rate-limiter/README.md index 20267a79e..52a6f01b0 100644 --- a/problems/logger-rate-limiter/README.md +++ b/problems/logger-rate-limiter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rearrange-string-k-distance-apart "Rearrange String k Distance Apart") diff --git a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md index ea4ae8c81..a95dfe168 100644 --- a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md +++ b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md @@ -64,6 +64,11 @@ The segment of 1s is not longer, so return false. ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) + 1. [Count Subarrays With More Ones Than Zeros](../count-subarrays-with-more-ones-than-zeros) (Medium) + 1. [Check if Binary String Has at Most One Segment of Ones](../check-if-binary-string-has-at-most-one-segment-of-ones) (Easy) + ### HintsHint 1
diff --git a/problems/longest-arithmetic-subsequence-of-given-difference/README.md b/problems/longest-arithmetic-subsequence-of-given-difference/README.md index 4158fbe84..dc350155e 100644 --- a/problems/longest-arithmetic-subsequence-of-given-difference/README.md +++ b/problems/longest-arithmetic-subsequence-of-given-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-move-chips-to-the-same-position "Minimum Cost to Move Chips to The Same Position") diff --git a/problems/longest-arithmetic-subsequence/README.md b/problems/longest-arithmetic-subsequence/README.md index a11e3f40c..33b7de800 100644 --- a/problems/longest-arithmetic-subsequence/README.md +++ b/problems/longest-arithmetic-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-difference-between-node-and-ancestor "Maximum Difference Between Node and Ancestor") diff --git a/problems/longest-chunked-palindrome-decomposition/README.md b/problems/longest-chunked-palindrome-decomposition/README.md index 6c7f56e26..6e555f50b 100644 --- a/problems/longest-chunked-palindrome-decomposition/README.md +++ b/problems/longest-chunked-palindrome-decomposition/README.md @@ -46,14 +46,6 @@ Explanation: We can split the string on "(a)(nt)(a)(pre)(za)(tpe)(za)(pre)(a)(nt)(a)".
Example 4:
- --Input: text = "aaa" -Output: 3 -Explanation: We can split the string on "(a)(a)(a)". --
Constraints:
diff --git a/problems/longest-common-subsequence-between-sorted-arrays/README.md b/problems/longest-common-subsequence-between-sorted-arrays/README.md index 3f9f604dc..1477353b8 100644 --- a/problems/longest-common-subsequence-between-sorted-arrays/README.md +++ b/problems/longest-common-subsequence-between-sorted-arrays/README.md @@ -18,6 +18,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) + ### HintsExample 3:
- --Input: s = "leetcodeleet" -Output: "leet" -- -
Example 4:
- --Input: s = "a" -Output: "" --
Constraints:
@@ -56,9 +42,9 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] [[String Matching](../../tag/string-matching/README.md)] [[Hash Function](../../tag/hash-function/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] ### HintsA string is called happy if it does not have any of the strings 'aaa', 'bbb' or 'ccc' as a substring.
Given three integers a, b and c, return any string s, which satisfies following conditions:
A string s is called happy if it satisfies the following conditions:
s is happy and longest possible.s contains at most a occurrences of the letter 'a', at most b occurrences of the letter 'b' and at most c occurrences of the letter 'c'.s will only contain 'a', 'b' and 'c' letters.s only contains the letters 'a', 'b', and 'c'.s does not contain any of "aaa", "bbb", or "ccc" as a substring.s contains at most a occurrences of the letter 'a'.s contains at most b occurrences of the letter 'b'.s contains at most c occurrences of the letter 'c'.If there is no such string s return the empty string "".
Given three integers a, b, and c, return the longest possible happy string. If there are multiple longest happy strings, return any of them. If there is no such string, return the empty string "".
A substring is a contiguous sequence of characters within a string.
Example 1:
@@ -34,17 +36,10 @@Example 2:
--Input: a = 2, b = 2, c = 1 -Output: "aabbc" -- -
Example 3:
-Input: a = 7, b = 1, c = 0 Output: "aabaa" -Explanation: It's the only correct answer in this case. +Explanation: It is the only correct answer in this case.
@@ -60,6 +55,9 @@ [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] +### Similar Questions + 1. [Reorganize String](../reorganize-string) (Medium) + ### Hints
Input: s = "Bb" Output: "Bb" -Explanation: "Bb" is a nice string because both 'B' and 'b' appear. The whole string is a substring.+Explanation: "Bb" is a nice string because both 'B' and 'b' appear. The whole string is a substring. +
Example 3:
Input: s = "c" Output: "" -Explanation: There are no nice substrings.- -
Example 4:
- --Input: s = "dDzeE" -Output: "dD" -Explanation: Both "dD" and "eE" are the longest nice substrings. -As there are multiple longest nice substrings, return "dD" since it occurs earlier.+Explanation: There are no nice substrings. +
Constraints:
diff --git a/problems/longest-palindrome-by-concatenating-two-letter-words/README.md b/problems/longest-palindrome-by-concatenating-two-letter-words/README.md new file mode 100644 index 000000000..3efa72307 --- /dev/null +++ b/problems/longest-palindrome-by-concatenating-two-letter-words/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../maximum-twin-sum-of-a-linked-list "Maximum Twin Sum of a Linked List") + +[Next >](../stamping-the-grid "Stamping the Grid") + +## [2131. Longest Palindrome by Concatenating Two Letter Words (Medium)](https://leetcode.com/problems/longest-palindrome-by-concatenating-two-letter-words "连接两字母单词得到的最长回文串") + +You are given an array of strings words. Each element of words consists of two lowercase English letters.
Create the longest possible palindrome by selecting some elements from words and concatenating them in any order. Each element can be selected at most once.
Return the length of the longest palindrome that you can create. If it is impossible to create any palindrome, return 0.
A palindrome is a string that reads the same forward and backward.
+ ++
Example 1:
+ ++Input: words = ["lc","cl","gg"] +Output: 6 +Explanation: One longest palindrome is "lc" + "gg" + "cl" = "lcggcl", of length 6. +Note that "clgglc" is another longest palindrome that can be created. ++ +
Example 2:
+ ++Input: words = ["ab","ty","yt","lc","cl","ab"] +Output: 8 +Explanation: One longest palindrome is "ty" + "lc" + "cl" + "yt" = "tylcclyt", of length 8. +Note that "lcyttycl" is another longest palindrome that can be created. ++ +
Example 3:
+ ++Input: words = ["cc","ll","xx"] +Output: 2 +Explanation: One longest palindrome is "cc", of length 2. +Note that "ll" is another longest palindrome that can be created, and so is "xx". ++ +
+
Constraints:
+ +1 <= words.length <= 105words[i].length == 2words[i] consists of lowercase English letters.Input: nums = [1,1,0,1] Output: 3 -Explanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's.+Explanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's. +
Example 2:
Input: nums = [0,1,1,1,0,1,1,0,1] Output: 5 -Explanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1].+Explanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1]. +
Example 3:
Input: nums = [1,1,1] Output: 2 -Explanation: You must delete one element.- -
Example 4:
- --Input: nums = [1,1,0,0,1,1,1,0,1] -Output: 4 -- -
Example 5:
- --Input: nums = [0,0,0] -Output: 0 +Explanation: You must delete one element.
diff --git a/problems/longest-subsequence-repeated-k-times/README.md b/problems/longest-subsequence-repeated-k-times/README.md index eb18b2de0..2879b957e 100644 --- a/problems/longest-subsequence-repeated-k-times/README.md +++ b/problems/longest-subsequence-repeated-k-times/README.md @@ -49,14 +49,6 @@ Explanation: There is no subsequence repeated 2 times. Empty string is returned. -
Example 4:
- --Input: s = "bbabbabbbbabaababab", k = 3 -Output: "bbbb" -Explanation: The longest subsequence "bbbb" is repeated 3 times in "bbabbabbbbabaababab". --
Constraints:
diff --git a/problems/longest-uncommon-subsequence-ii/README.md b/problems/longest-uncommon-subsequence-ii/README.md index 218b3d5fd..be9dd896a 100644 --- a/problems/longest-uncommon-subsequence-ii/README.md +++ b/problems/longest-uncommon-subsequence-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-uncommon-subsequence-i "Longest Uncommon Subsequence I") diff --git a/problems/longest-univalue-path/README.md b/problems/longest-univalue-path/README.md index de2efc274..87333d2cc 100644 --- a/problems/longest-univalue-path/README.md +++ b/problems/longest-univalue-path/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../repeated-string-match "Repeated String Match") diff --git a/problems/longest-winning-streak/README.md b/problems/longest-winning-streak/README.md new file mode 100644 index 000000000..d136c15df --- /dev/null +++ b/problems/longest-winning-streak/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../maximum-and-sum-of-array "Maximum AND Sum of Array") + +Next > + +## [2173. Longest Winning Streak (Hard)](https://leetcode.com/problems/longest-winning-streak "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/longest-winning-streak/mysql_schemas.sql b/problems/longest-winning-streak/mysql_schemas.sql new file mode 100644 index 000000000..6da5cb0fb --- /dev/null +++ b/problems/longest-winning-streak/mysql_schemas.sql @@ -0,0 +1,10 @@ +Create table If Not Exists Matches (player_id int, match_day date, result ENUM('Win', 'Draw', 'Lose')); +Truncate table Matches; +insert into Matches (player_id, match_day, result) values ('1', '2022-01-17', 'Win'); +insert into Matches (player_id, match_day, result) values ('1', '2022-01-18', 'Win'); +insert into Matches (player_id, match_day, result) values ('1', '2022-01-25', 'Win'); +insert into Matches (player_id, match_day, result) values ('1', '2022-01-31', 'Draw'); +insert into Matches (player_id, match_day, result) values ('1', '2022-02-08', 'Win'); +insert into Matches (player_id, match_day, result) values ('2', '2022-02-06', 'Lose'); +insert into Matches (player_id, match_day, result) values ('2', '2022-02-08', 'Lose'); +insert into Matches (player_id, match_day, result) values ('3', '2022-03-30', 'Win'); diff --git a/problems/low-quality-problems/README.md b/problems/low-quality-problems/README.md index 9daaf212c..09b5a0c7a 100644 --- a/problems/low-quality-problems/README.md +++ b/problems/low-quality-problems/README.md @@ -9,7 +9,7 @@ [Next >](../minimum-moves-to-convert-string "Minimum Moves to Convert String") -## [2026. Low-Quality Problems (Easy)](https://leetcode.com/problems/low-quality-problems "") +## [2026. Low-Quality Problems (Easy)](https://leetcode.com/problems/low-quality-problems "低质量的问题") diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md index 026487e5f..a616f79c8 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md @@ -18,6 +18,14 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) + 1. [Lowest Common Ancestor of a Binary Tree](../lowest-common-ancestor-of-a-binary-tree) (Medium) + 1. [Lowest Common Ancestor of Deepest Leaves](../lowest-common-ancestor-of-deepest-leaves) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree II](../lowest-common-ancestor-of-a-binary-tree-ii) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree III](../lowest-common-ancestor-of-a-binary-tree-iii) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree IV](../lowest-common-ancestor-of-a-binary-tree-iv) (Medium) + ### HintsGiven an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.
Follow-up: Could you solve the problem in linear time and in O(1) space?
-
Example 1:
@@ -45,11 +43,14 @@-109 <= nums[i] <= 109+
Follow up: Could you solve the problem in linear time and in O(1) space?
Example 4:
- --Input: nums = [1,2,3], p = 7 -Output: -1 -Explanation: There is no way to remove a subarray in order to get a sum divisible by 7. -- -
Example 5:
- --Input: nums = [1000000000,1000000000,1000000000], p = 3 -Output: 0 --
Constraints:
diff --git a/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md b/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md index 7ccaa9fe5..3f98c203d 100644 --- a/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md +++ b/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rectangles-area "Rectangles Area") @@ -11,11 +11,9 @@ ## [1460. Make Two Arrays Equal by Reversing Sub-arrays (Easy)](https://leetcode.com/problems/make-two-arrays-equal-by-reversing-sub-arrays "通过翻转子数组使两个数组相等") -Given two integer arrays of equal length target and arr.
You are given two integer arrays of equal length target and arr. In one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any number of steps.
In one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any number of steps.
Return True if you can make arr equal to target, or False otherwise.
Return true if you can make arr equal to target or false otherwise.
Example 1:
@@ -40,24 +38,10 @@ There are multiple ways to convert arr to target, this is not the only way to doExample 3:
--Input: target = [1,12], arr = [12,1] -Output: true -- -
Example 4:
-Input: target = [3,7,9], arr = [3,7,11] Output: false -Explanation: arr doesn't have value 9 and it can never be converted to target. -- -
Example 5:
- --Input: target = [1,1,1,1,1], arr = [1,1,1,1,1] -Output: true +Explanation: arr does not have value 9 and it can never be converted to target.
diff --git a/problems/making-file-names-unique/README.md b/problems/making-file-names-unique/README.md index dc950449f..0b8995d41 100644 --- a/problems/making-file-names-unique/README.md +++ b/problems/making-file-names-unique/README.md @@ -11,11 +11,11 @@ ## [1487. Making File Names Unique (Medium)](https://leetcode.com/problems/making-file-names-unique "保证文件名唯一") -
Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i].
Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i].
Since two files cannot have the same name, if you enter a folder name which is previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique.
Since two files cannot have the same name, if you enter a folder name that was previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique.
Return an array of strings of length n where ans[i] is the actual name the system will assign to the ith folder when you create it.
Return an array of strings of length n where ans[i] is the actual name the system will assign to the ith folder when you create it.
Example 1:
@@ -50,29 +50,13 @@ Explanation: When the last folder is created, the smallest positive valid k is 4, and it becomes "onepiece(4)". -Example 4:
- --Input: names = ["wano","wano","wano","wano"] -Output: ["wano","wano(1)","wano(2)","wano(3)"] -Explanation: Just increase the value of k each time you create folder "wano". -- -
Example 5:
- --Input: names = ["kaido","kaido(1)","kaido","kaido(1)"] -Output: ["kaido","kaido(1)","kaido(2)","kaido(1)(1)"] -Explanation: Please note that system adds the suffix (k) to current name even it contained the same suffix before. --
Constraints:
1 <= names.length <= 5 * 10^41 <= names.length <= 5 * 1041 <= names[i].length <= 20names[i] consists of lower case English letters, digits and/or round brackets.names[i] consists of lowercase English letters, digits, and/or round brackets.Example 2:
--Input: matrix = [] -Output: 0 -- -
Example 3:
-Input: matrix = [["0"]] Output: 0-
Example 4:
+Example 3:
Input: matrix = [["1"]] Output: 1-
Example 5:
- --Input: matrix = [["0","0"]] -Output: 0 --
Constraints:
rows == matrix.lengthcols == matrix[i].length0 <= row, cols <= 2001 <= row, cols <= 200matrix[i][j] is '0' or '1'.You are given an integer array nums of length n and an integer numSlots such that 2 * numSlots >= n. There are numSlots slots numbered from 1 to numSlots.
You have to place all n integers into the slots such that each slot contains at most two numbers. The AND sum of a given placement is the sum of the bitwise AND of every number with its respective slot number.
[1, 3] into slot 1 and [4, 6] into slot 2 is equal to (1 AND 1) + (3 AND 1) + (4 AND 2) + (6 AND 2) = 1 + 1 + 0 + 2 = 4.Return the maximum possible AND sum of nums given numSlots slots.
+
Example 1:
+ ++Input: nums = [1,2,3,4,5,6], numSlots = 3 +Output: 9 +Explanation: One possible placement is [1, 4] into slot 1, [2, 6] into slot 2, and [3, 5] into slot 3. +This gives the maximum AND sum of (1 AND 1) + (4 AND 1) + (2 AND 2) + (6 AND 2) + (3 AND 3) + (5 AND 3) = 1 + 0 + 2 + 2 + 3 + 1 = 9. ++ +
Example 2:
+ ++Input: nums = [1,3,10,4,7,1], numSlots = 9 +Output: 24 +Explanation: One possible placement is [1, 1] into slot 1, [3] into slot 3, [4] into slot 4, [7] into slot 7, and [10] into slot 9. +This gives the maximum AND sum of (1 AND 1) + (1 AND 1) + (3 AND 3) + (4 AND 4) + (7 AND 7) + (10 AND 9) = 1 + 1 + 3 + 4 + 7 + 8 = 24. +Note that slots 2, 5, 6, and 8 are empty which is permitted. ++ +
+
Constraints:
+ +n == nums.length1 <= numSlots <= 91 <= n <= 2 * numSlots1 <= nums[i] <= 15Example 4:
- --Input: nums = [100,10,1] -Output: 100 --
Constraints:
@@ -60,6 +53,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [Find Good Days to Rob the Bank](../find-good-days-to-rob-the-bank) (Medium) + ### HintsGiven n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
You have n boxes labeled from 0 to n - 1. You are given four arrays: status, candies, keys, and containedBoxes where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.candies[i]: an integer representing the number of candies in box[i].keys[i]: an array contains the indices of the boxes you can open with the key in box[i].containedBoxes[i]: an array contains the indices of the boxes found in box[i].status[i] is 1 if the ith box is open and 0 if the ith box is closed,candies[i] is the number of candies in the ith box,keys[i] is a list of the labels of the boxes you can open after opening the ith box.containedBoxes[i] is a list of the boxes you found inside the ith box.You will start with some boxes given in initialBoxes array. You can take all the candies in any open box and you can use the keys in it to open new boxes and you also can use the boxes you find in it.
You are given an integer array initialBoxes that contains the labels of the boxes you initially have. You can take all the candies in any open box and you can use the keys in it to open new boxes and you also can use the boxes you find in it.
Return the maximum number of candies you can get following the rules above.
+Return the maximum number of candies you can get following the rules above.
Example 1:
@@ -30,7 +30,8 @@Input: status = [1,0,1,0], candies = [7,5,4,100], keys = [[],[],[1],[]], containedBoxes = [[1,2],[3],[],[]], initialBoxes = [0] Output: 16 -Explanation: You will be initially given box 0. You will find 7 candies in it and boxes 1 and 2. Box 1 is closed and you don't have a key for it so you will open box 2. You will find 4 candies and a key to box 1 in box 2. +Explanation: You will be initially given box 0. You will find 7 candies in it and boxes 1 and 2. +Box 1 is closed and you do not have a key for it so you will open box 2. You will find 4 candies and a key to box 1 in box 2. In box 1, you will find 5 candies and box 3 but you will not find a key to box 3 so box 3 will remain closed. Total number of candies collected = 7 + 4 + 5 = 16 candy.@@ -40,52 +41,32 @@ Total number of candies collected = 7 + 4 + 5 = 16 candy.
Input: status = [1,0,0,0,0,0], candies = [1,1,1,1,1,1], keys = [[1,2,3,4,5],[],[],[],[],[]], containedBoxes = [[1,2,3,4,5],[],[],[],[],[]], initialBoxes = [0] Output: 6 -Explanation: You have initially box 0. Opening it you can find boxes 1,2,3,4 and 5 and their keys. The total number of candies will be 6. -- -
Example 3:
- --Input: status = [1,1,1], candies = [100,1,100], keys = [[],[0,2],[]], containedBoxes = [[],[],[]], initialBoxes = [1] -Output: 1 -- -
Example 4:
- --Input: status = [1], candies = [100], keys = [[]], containedBoxes = [[]], initialBoxes = [] -Output: 0 -- -
Example 5:
- --Input: status = [1,1,1], candies = [2,3,2], keys = [[],[],[]], containedBoxes = [[],[],[]], initialBoxes = [2,1,0] -Output: 7 +Explanation: You have initially box 0. Opening it you can find boxes 1,2,3,4 and 5 and their keys. +The total number of candies will be 6.
Constraints:
1 <= status.length <= 1000status.length == candies.length == keys.length == containedBoxes.length == nstatus[i] is 0 or 1.n == status.length == candies.length == keys.length == containedBoxes.length1 <= n <= 1000status[i] is either 0 or 1.1 <= candies[i] <= 10000 <= keys[i].length <= status.length0 <= keys[i][j] < status.lengthkeys[i] are unique.0 <= containedBoxes[i].length <= status.length0 <= containedBoxes[i][j] < status.lengthcontainedBoxes[i] are unique.0 <= keys[i].length <= n0 <= keys[i][j] < nkeys[i] are unique.0 <= containedBoxes[i].length <= n0 <= containedBoxes[i][j] < ncontainedBoxes[i] are unique.0 <= initialBoxes.length <= status.length0 <= initialBoxes[i] < status.length0 <= initialBoxes.length <= n0 <= initialBoxes[i] < nExample 4:
- --Input: nums1 = [5,4], nums2 = [3,2] -Output: 0 -Explanation: There are no valid pairs, so return 0. --
Constraints:
diff --git a/problems/maximum-distance-in-arrays/README.md b/problems/maximum-distance-in-arrays/README.md index b9bcdb2a2..4190a9404 100644 --- a/problems/maximum-distance-in-arrays/README.md +++ b/problems/maximum-distance-in-arrays/README.md @@ -35,5 +35,5 @@ One way to reach the maximum distance 4 is to pick 1 in the first or third array ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-element-after-decreasing-and-rearranging/README.md b/problems/maximum-element-after-decreasing-and-rearranging/README.md index 2ec14e72a..b3c3ef248 100644 --- a/problems/maximum-element-after-decreasing-and-rearranging/README.md +++ b/problems/maximum-element-after-decreasing-and-rearranging/README.md @@ -69,8 +69,8 @@ The largest element inarr is 3.
### Related Topics
- [[Greedy](../../tag/greedy/README.md)]
[[Array](../../tag/array/README.md)]
+ [[Greedy](../../tag/greedy/README.md)]
[[Sorting](../../tag/sorting/README.md)]
### Hints
diff --git a/problems/maximum-employees-to-be-invited-to-a-meeting/README.md b/problems/maximum-employees-to-be-invited-to-a-meeting/README.md
new file mode 100644
index 000000000..b593c81e1
--- /dev/null
+++ b/problems/maximum-employees-to-be-invited-to-a-meeting/README.md
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+[< Previous](../destroying-asteroids "Destroying Asteroids")
+
+[Next >](../remove-all-ones-with-row-and-column-flips "Remove All Ones With Row and Column Flips")
+
+## [2127. Maximum Employees to Be Invited to a Meeting (Hard)](https://leetcode.com/problems/maximum-employees-to-be-invited-to-a-meeting "参加会议的最多员工数")
+
+A company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a large circular table, capable of seating any number of employees.
The employees are numbered from 0 to n - 1. Each employee has a favorite person and they will attend the meeting only if they can sit next to their favorite person at the table. The favorite person of an employee is not themself.
Given a 0-indexed integer array favorite, where favorite[i] denotes the favorite person of the ith employee, return the maximum number of employees that can be invited to the meeting.
+
Example 1:
+
++Input: favorite = [2,2,1,2] +Output: 3 +Explanation: +The above figure shows how the company can invite employees 0, 1, and 2, and seat them at the round table. +All employees cannot be invited because employee 2 cannot sit beside employees 0, 1, and 3, simultaneously. +Note that the company can also invite employees 1, 2, and 3, and give them their desired seats. +The maximum number of employees that can be invited to the meeting is 3. ++ +
Example 2:
+ ++Input: favorite = [1,2,0] +Output: 3 +Explanation: +Each employee is the favorite person of at least one other employee, and the only way the company can invite them is if they invite every employee. +The seating arrangement will be the same as that in the figure given in example 1: +- Employee 0 will sit between employees 2 and 1. +- Employee 1 will sit between employees 0 and 2. +- Employee 2 will sit between employees 1 and 0. +The maximum number of employees that can be invited to the meeting is 3. ++ +
Example 3:
+
++Input: favorite = [3,0,1,4,1] +Output: 4 +Explanation: +The above figure shows how the company will invite employees 0, 1, 3, and 4, and seat them at the round table. +Employee 2 cannot be invited because the two spots next to their favorite employee 1 are taken. +So the company leaves them out of the meeting. +The maximum number of employees that can be invited to the meeting is 4. ++ +
+
Constraints:
+ +n == favorite.length2 <= n <= 1050 <= favorite[i] <= n - 1favorite[i] != iFruits are available at some positions on an infinite x-axis. You are given a 2D integer array fruits where fruits[i] = [positioni, amounti] depicts amounti fruits at the position positioni. fruits is already sorted by positioni in ascending order, and each positioni is unique.
You are also given an integer startPos and an integer k. Initially, you are at the position startPos. From any position, you can either walk to the left or right. It takes one step to move one unit on the x-axis, and you can walk at most k steps in total. For every position you reach, you harvest all the fruits at that position, and the fruits will disappear from that position.
Return the maximum total number of fruits you can harvest.
+ ++
Example 1:
+
++Input: fruits = [[2,8],[6,3],[8,6]], startPos = 5, k = 4 +Output: 9 +Explanation: +The optimal way is to: +- Move right to position 6 and harvest 3 fruits +- Move right to position 8 and harvest 6 fruits +You moved 3 steps and harvested 3 + 6 = 9 fruits in total. ++ +
Example 2:
+
++Input: fruits = [[0,9],[4,1],[5,7],[6,2],[7,4],[10,9]], startPos = 5, k = 4 +Output: 14 +Explanation: +You can move at most k = 4 steps, so you cannot reach position 0 nor 10. +The optimal way is to: +- Harvest the 7 fruits at the starting position 5 +- Move left to position 4 and harvest 1 fruit +- Move right to position 6 and harvest 2 fruits +- Move right to position 7 and harvest 4 fruits +You moved 1 + 3 = 4 steps and harvested 7 + 1 + 2 + 4 = 14 fruits in total. ++ +
Example 3:
+
++Input: fruits = [[0,3],[6,4],[8,5]], startPos = 3, k = 2 +Output: 0 +Explanation: +You can move at most k = 2 steps and cannot reach any position with fruits. ++ +
+
Constraints:
+ +1 <= fruits.length <= 105fruits[i].length == 20 <= startPos, positioni <= 2 * 105positioni-1 < positioni for any i > 0 (0-indexed)1 <= amounti <= 1040 <= k <= 2 * 1050 <= vali <= 2 * 105There are two types of persons:
+ +You are given a 0-indexed 2D integer array statements of size n x n that represents the statements made by n people about each other. More specifically, statements[i][j] could be one of the following:
0 which represents a statement made by person i that person j is a bad person.1 which represents a statement made by person i that person j is a good person.2 represents that no statement is made by person i about person j.Additionally, no person ever makes a statement about themselves. Formally, we have that statements[i][i] = 2 for all 0 <= i < n.
Return the maximum number of people who can be good based on the statements made by the n people.
+
Example 1:
+
++Input: statements = [[2,1,2],[1,2,2],[2,0,2]] +Output: 2 +Explanation: Each person makes a single statement. +- Person 0 states that person 1 is good. +- Person 1 states that person 0 is good. +- Person 2 states that person 1 is bad. +Let's take person 2 as the key. +- Assuming that person 2 is a good person: + - Based on the statement made by person 2, person 1 is a bad person. + - Now we know for sure that person 1 is bad and person 2 is good. + - Based on the statement made by person 1, and since person 1 is bad, they could be: + - telling the truth. There will be a contradiction in this case and this assumption is invalid. + - lying. In this case, person 0 is also a bad person and lied in their statement. + - Following that person 2 is a good person, there will be only one good person in the group. +- Assuming that person 2 is a bad person: + - Based on the statement made by person 2, and since person 2 is bad, they could be: + - telling the truth. Following this scenario, person 0 and 1 are both bad as explained before. + - Following that person 2 is bad but told the truth, there will be no good persons in the group. + - lying. In this case person 1 is a good person. + - Since person 1 is a good person, person 0 is also a good person. + - Following that person 2 is bad and lied, there will be two good persons in the group. +We can see that at most 2 persons are good in the best case, so we return 2. +Note that there is more than one way to arrive at this conclusion. ++ +
Example 2:
+
++Input: statements = [[2,0],[0,2]] +Output: 1 +Explanation: Each person makes a single statement. +- Person 0 states that person 1 is bad. +- Person 1 states that person 0 is bad. +Let's take person 0 as the key. +- Assuming that person 0 is a good person: + - Based on the statement made by person 0, person 1 is a bad person and was lying. + - Following that person 0 is a good person, there will be only one good person in the group. +- Assuming that person 0 is a bad person: + - Based on the statement made by person 0, and since person 0 is bad, they could be: + - telling the truth. Following this scenario, person 0 and 1 are both bad. + - Following that person 0 is bad but told the truth, there will be no good persons in the group. + - lying. In this case person 1 is a good person. + - Following that person 0 is bad and lied, there will be only one good person in the group. +We can see that at most, one person is good in the best case, so we return 1. +Note that there is more than one way to arrive at this conclusion. ++ +
+
Constraints:
+ +n == statements.length == statements[i].length2 <= n <= 15statements[i][j] is either 0, 1, or 2.statements[i][i] == 2Example 4:
- --Input: arr = ["aa","bb"] -Output: 0 -Explanation: Both strings in arr do not have unique characters, thus there are no valid concatenations. --
Constraints:
diff --git a/problems/maximum-length-of-subarray-with-positive-product/README.md b/problems/maximum-length-of-subarray-with-positive-product/README.md index 09559fc46..d1b1c444c 100644 --- a/problems/maximum-length-of-subarray-with-positive-product/README.md +++ b/problems/maximum-length-of-subarray-with-positive-product/README.md @@ -11,11 +11,11 @@ ## [1567. Maximum Length of Subarray With Positive Product (Medium)](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") -Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive.
Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive.
A subarray of an array is a consecutive sequence of zero or more values taken out of that array.
-Return the maximum length of a subarray with positive product.
+Return the maximum length of a subarray with positive product.
Example 1:
@@ -23,7 +23,7 @@Input: nums = [1,-2,-3,4] Output: 4 -Explanation: The array nums already has a positive product of 24. +Explanation: The array nums already has a positive product of 24.
Example 2:
@@ -31,7 +31,7 @@Input: nums = [0,1,-2,-3,-4] Output: 3 -Explanation: The longest subarray with positive product is [1,-2,-3] which has a product of 6. +Explanation: The longest subarray with positive product is [1,-2,-3] which has a product of 6. Notice that we cannot include 0 in the subarray since that'll make the product 0 which is not positive.
Example 3:
@@ -39,35 +39,21 @@ Notice that we cannot include 0 in the subarray since that'll make the produInput: nums = [-1,-2,-3,0,1] Output: 2 -Explanation: The longest subarray with positive product is [-1,-2] or [-2,-3]. -- -
Example 4:
- --Input: nums = [-1,2] -Output: 1 -- -
Example 5:
- --Input: nums = [1,2,3,5,-6,4,0,10] -Output: 4 +Explanation: The longest subarray with positive product is [-1,-2] or [-2,-3].
Constraints:
1 <= nums.length <= 10^5-10^9 <= nums[i] <= 10^91 <= nums.length <= 105-109 <= nums[i] <= 109Example 3:
- --Input: s = "1+(2*3)/(2-1)" -Output: 1 -- -
Example 4:
- --Input: s = "1" -Output: 0 --
Constraints:
@@ -72,8 +58,11 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + +### Similar Questions + 1. [Maximum Nesting Depth of Two Valid Parentheses Strings](../maximum-nesting-depth-of-two-valid-parentheses-strings) (Medium) ### HintsYou are given a rows x cols matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix.
You are given a m x n matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix.
Among all possible paths starting from the top-left corner (0, 0) and ending in the bottom-right corner (rows - 1, cols - 1), find the path with the maximum non-negative product. The product of a path is the product of all integers in the grid cells visited along the path.
Among all possible paths starting from the top-left corner (0, 0) and ending in the bottom-right corner (m - 1, n - 1), find the path with the maximum non-negative product. The product of a path is the product of all integers in the grid cells visited along the path.
Return the maximum non-negative product modulo 109 + 7. If the maximum product is negative return -1.
Return the maximum non-negative product modulo 109 + 7. If the maximum product is negative, return -1.
Notice that the modulo is performed after getting the maximum product.
+Notice that the modulo is performed after getting the maximum product.
Example 1:
- +
-Input: grid = [[-1,-2,-3], - [-2,-3,-3], - [-3,-3,-2]] +Input: grid = [[-1,-2,-3],[-2,-3,-3],[-3,-3,-2]] Output: -1 -Explanation: It's not possible to get non-negative product in the path from (0, 0) to (2, 2), so return -1. +Explanation: It is not possible to get non-negative product in the path from (0, 0) to (2, 2), so return -1.
Example 2:
- +
-Input: grid = [[1,-2,1], - [1,-2,1], - [3,-4,1]] +Input: grid = [[1,-2,1],[1,-2,1],[3,-4,1]] Output: 8 -Explanation: Maximum non-negative product is in bold (1 * 1 * -2 * -4 * 1 = 8). +Explanation: Maximum non-negative product is shown (1 * 1 * -2 * -4 * 1 = 8).
Example 3:
- +
-Input: grid = [[1, 3], - [0,-4]] +Input: grid = [[1,3],[0,-4]] Output: 0 -Explanation: Maximum non-negative product is in bold (1 * 0 * -4 = 0). -- -
Example 4:
- --Input: grid = [[ 1, 4,4,0], - [-2, 0,0,1], - [ 1,-1,1,1]] -Output: 2 -Explanation: Maximum non-negative product is in bold (1 * -2 * 1 * -1 * 1 * 1 = 2). +Explanation: Maximum non-negative product is shown (1 * 0 * -4 = 0).
Constraints:
1 <= rows, cols <= 15m == grid.lengthn == grid[i].length1 <= m, n <= 15-4 <= grid[i][j] <= 4You have a very large square wall and a circular dartboard placed on the wall. You have been challenged to throw darts into the board blindfolded. Darts thrown at the wall are represented as an array of points on a 2D plane.
Alice is throwing n darts on a very large wall. You are given an array darts where darts[i] = [xi, yi] is the position of the ith dart that Alice threw on the wall.
Return the maximum number of points that are within or lie on any circular dartboard of radius r.
Bob knows the positions of the n darts on the wall. He wants to place a dartboard of radius r on the wall so that the maximum number of darts that Alice throws lies on the dartboard.
Given the integer r, return the maximum number of darts that can lie on the dartboard.
Example 1:
- -
-Input: points = [[-2,0],[2,0],[0,2],[0,-2]], r = 2 +Input: darts = [[-2,0],[2,0],[0,2],[0,-2]], r = 2 Output: 4 Explanation: Circle dartboard with center in (0,0) and radius = 2 contain all points.
Example 2:
- -
-Input: points = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5 +Input: darts = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5 Output: 5 Explanation: Circle dartboard with center in (0,4) and radius = 5 contain all points except the point (7,8).-
Example 3:
- --Input: points = [[-2,0],[2,0],[0,2],[0,-2]], r = 1 -Output: 1 -- -
Example 4:
- --Input: points = [[1,2],[3,5],[1,-1],[2,3],[4,1],[1,3]], r = 2 -Output: 4 --
Constraints:
1 <= points.length <= 100points[i].length == 2-10^4 <= points[i][0], points[i][1] <= 10^41 <= darts.length <= 100darts[i].length == 2-104 <= xi, yi <= 1041 <= r <= 5000Constraints:
apples.length == ndays.length == nn == apples.length == days.length1 <= n <= 2 * 1040 <= apples[i], days[i] <= 2 * 104days[i] = 0 if and only if apples[i] = 0.Given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.
You are given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.
You can attend an event i at any day d where startTimei <= d <= endTimei. Notice that you can only attend one event at any time d.
You can attend an event i at any day d where startTimei <= d <= endTimei. You can only attend one event at any time d.
Return the maximum number of events you can attend.
+Return the maximum number of events you can attend.
Example 1:
-
+
Input: events = [[1,2],[2,3],[3,4]] Output: 3 @@ -37,27 +37,6 @@ Attend the third event on day 3. Output: 4-
Example 3:
- --Input: events = [[1,4],[4,4],[2,2],[3,4],[1,1]] -Output: 4 -- -
Example 4:
- --Input: events = [[1,100000]] -Output: 1 -- -
Example 5:
- --Input: events = [[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7]] -Output: 7 --
Constraints:
@@ -68,14 +47,10 @@ Attend the third event on day 3. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] -### Similar Questions - 1. [Maximum Number of Events That Can Be Attended II](../maximum-number-of-events-that-can-be-attended-ii) (Hard) - 1. [Maximum Earnings From Taxi](../maximum-earnings-from-taxi) (Medium) - ### HintsGiven an array nums and an integer target.
Return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.
Given an array nums and an integer target, return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.
Example 1:
@@ -21,7 +19,7 @@Input: nums = [1,1,1,1,1], target = 2 Output: 2 -Explanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to target(2). +Explanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to target(2).
Example 2:
@@ -29,36 +27,23 @@Input: nums = [-1,3,5,1,4,2,-9], target = 6 Output: 2 -Explanation: There are 3 subarrays with sum equal to 6. -([5,1], [4,2], [3,5,1,4,2,-9]) but only the first 2 are non-overlapping.- -
Example 3:
- --Input: nums = [-2,6,6,3,5,4,1,2,8], target = 10 -Output: 3 -- -
Example 4:
- --Input: nums = [0,0,0], target = 0 -Output: 3 +Explanation: There are 3 subarrays with sum equal to 6. +([5,1], [4,2], [3,5,1,4,2,-9]) but only the first 2 are non-overlapping.
Constraints:
1 <= nums.length <= 10^5-10^4 <= nums[i] <= 10^40 <= target <= 10^61 <= nums.length <= 105-104 <= nums[i] <= 1040 <= target <= 106Given a string s, return the maximum number of ocurrences of any substring under the following rules:
Given a string s, return the maximum number of ocurrences of any substring under the following rules:
maxLetters.minSize and maxSize inclusive.minSize and maxSize inclusive.@@ -36,28 +36,14 @@ It satisfies the conditions, 2 unique letters and size 3 (between minSize and ma Explanation: Substring "aaa" occur 2 times in the string. It can overlap. -
Example 3:
- --Input: s = "aabcabcab", maxLetters = 2, minSize = 2, maxSize = 3 -Output: 3 -- -
Example 4:
- --Input: s = "abcde", maxLetters = 2, minSize = 3, maxSize = 3 -Output: 0 --
Constraints:
1 <= s.length <= 10^51 <= s.length <= 1051 <= maxLetters <= 261 <= minSize <= maxSize <= min(26, s.length)s only contains lowercase English letters.s consists of only lowercase English letters.Example 4:
- --Input: tasks = [5,9,8,5,9], workers = [1,6,4,2,6], pills = 1, strength = 5 -Output: 3 -Explanation: -We can assign the magical pill and tasks as follows: -- Give the magical pill to worker 2. -- Assign worker 1 to task 0 (6 >= 5) -- Assign worker 2 to task 2 (4 + 5 >= 8) -- Assign worker 4 to task 3 (6 >= 5) +The last pill is not given because it will not make any worker strong enough for the last task.
diff --git a/problems/maximum-number-of-visible-points/README.md b/problems/maximum-number-of-visible-points/README.md index 1dcf62a62..f9401d886 100644 --- a/problems/maximum-number-of-visible-points/README.md +++ b/problems/maximum-number-of-visible-points/README.md @@ -62,11 +62,11 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Sorting](../../tag/sorting/README.md)] + [[Geometry](../../tag/geometry/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
Given a string s and an integer k.
Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.
Return the maximum number of vowel letters in any substring of s with length k.
Vowel letters in English are (a, e, i, o, u).
+Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.
Example 1:
@@ -42,27 +40,12 @@ Explanation: "lee", "eet" and "ode" contain 2 vowels. -Example 4:
- --Input: s = "rhythms", k = 4 -Output: 0 -Explanation: We can see that s doesn't have any vowel letters. -- -
Example 5:
- --Input: s = "tryhard", k = 4 -Output: 1 --
Constraints:
1 <= s.length <= 10^5s consists of lowercase English letters.1 <= s.length <= 105s consists of lowercase English letters.1 <= k <= s.lengthA sentence is a list of words that are separated by a single space with no leading or trailing spaces.
+ +You are given an array of strings sentences, where each sentences[i] represents a single sentence.
Return the maximum number of words that appear in a single sentence.
+ ++
Example 1:
+ ++Input: sentences = ["alice and bob love leetcode", "i think so too", "this is great thanks very much"] +Output: 6 +Explanation: +- The first sentence, "alice and bob love leetcode", has 5 words in total. +- The second sentence, "i think so too", has 4 words in total. +- The third sentence, "this is great thanks very much", has 6 words in total. +Thus, the maximum number of words in a single sentence comes from the third sentence, which has 6 words. ++ +
Example 2:
+ ++Input: sentences = ["please wait", "continue to fight", "continue to win"] +Output: 3 +Explanation: It is possible that multiple sentences contain the same number of words. +In this example, the second and third sentences (underlined) have the same number of words. ++ +
+
Constraints:
+ +1 <= sentences.length <= 1001 <= sentences[i].length <= 100sentences[i] consists only of lowercase English letters and ' ' only.sentences[i] does not have leading or trailing spaces.sentences[i] are separated by a single space.Example 4:
- -
-Input: values = [0,1,2], edges = [[1,2,10]], maxTime = 10 -Output: 0 -Explanation: -The only path is 0. The total time taken is 0. -The only node visited is 0, giving a maximal path quality of 0. +The nodes visited are 0, 1, and 3, giving a maximal path quality of 1 + 2 + 4 = 7.
diff --git a/problems/maximum-performance-of-a-team/README.md b/problems/maximum-performance-of-a-team/README.md index 4bf572f41..875210e17 100644 --- a/problems/maximum-performance-of-a-team/README.md +++ b/problems/maximum-performance-of-a-team/README.md @@ -62,6 +62,9 @@ We have the maximum performance of the team by selecting engineer 2 (with speed= [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] +### Similar Questions + 1. [Maximum Fruits Harvested After at Most K Steps](../maximum-fruits-harvested-after-at-most-k-steps) (Hard) + ### Hints
Example 4:
- --Input: cardPoints = [1,1000,1], k = 1 -Output: 1 -Explanation: You cannot take the card in the middle. Your best score is 1. -- -
Example 5:
- --Input: cardPoints = [1,79,80,1,1,1,200,1], k = 3 -Output: 202 --
Constraints:
@@ -70,8 +55,12 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Similar Questions + 1. [Maximum Score from Performing Multiplication Operations](../maximum-score-from-performing-multiplication-operations) (Medium) + 1. [Removing Minimum and Maximum From Array](../removing-minimum-and-maximum-from-array) (Medium) ### HintsExample 3:
- --Input: root = [2,3,9,10,7,8,6,5,4,11,1] -Output: 1025 -- -
Example 4:
- --Input: root = [1,1] -Output: 1 --
Constraints:
diff --git a/problems/maximum-product-of-word-lengths/README.md b/problems/maximum-product-of-word-lengths/README.md index 32a3e74c8..40fec0598 100644 --- a/problems/maximum-product-of-word-lengths/README.md +++ b/problems/maximum-product-of-word-lengths/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-distance-from-all-buildings "Shortest Distance from All Buildings") diff --git a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md index f638ef1e3..0ef854aa3 100644 --- a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md +++ b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md @@ -21,7 +21,7 @@
Example 1:
-
+
Input: customers = [8,3], boardingCost = 5, runningCost = 6 Output: 3 @@ -29,7 +29,8 @@ 1. 8 customers arrive, 4 board and 4 wait for the next gondola, the wheel rotates. Current profit is 4 * $5 - 1 * $6 = $14. 2. 3 customers arrive, the 4 waiting board the wheel and the other 3 wait, the wheel rotates. Current profit is 8 * $5 - 2 * $6 = $28. 3. The final 3 customers board the gondola, the wheel rotates. Current profit is 11 * $5 - 3 * $6 = $37. -The highest profit was $37 after rotating the wheel 3 times.+The highest profit was $37 after rotating the wheel 3 times. +
Example 2:
@@ -45,7 +46,6 @@ The highest profit was $37 after rotating the wheel 3 times. 6. 4 board and 1 waits, the wheel rotates. Current profit is 24 * $6 - 6 * $4 = $120. 7. 1 boards, the wheel rotates. Current profit is 25 * $6 - 7 * $4 = $122. The highest profit was $122 after rotating the wheel 7 times. -Example 3:
@@ -62,25 +62,6 @@ The highest profit was $122 after rotating the wheel 7 times. The profit was never positive, so return -1. -Example 4:
- --Input: customers = [10,10,6,4,7], boardingCost = 3, runningCost = 8 -Output: 9 -Explanation: -1. 10 customers arrive, 4 board and 6 wait, the wheel rotates. Current profit is 4 * $3 - 1 * $8 = $4. -2. 10 customers arrive, 4 board and 12 wait, the wheel rotates. Current profit is 8 * $3 - 2 * $8 = $8. -3. 6 customers arrive, 4 board and 14 wait, the wheel rotates. Current profit is 12 * $3 - 3 * $8 = $12. -4. 4 customers arrive, 4 board and 14 wait, the wheel rotates. Current profit is 16 * $3 - 4 * $8 = $16. -5. 7 customers arrive, 4 board and 17 wait, the wheel rotates. Current profit is 20 * $3 - 5 * $8 = $20. -6. 4 board and 13 wait, the wheel rotates. Current profit is 24 * $3 - 6 * $8 = $24. -7. 4 board and 9 wait, the wheel rotates. Current profit is 28 * $3 - 7 * $8 = $28. -8. 4 board and 5 wait, the wheel rotates. Current profit is 32 * $3 - 8 * $8 = $32. -9. 4 board and 1 waits, the wheel rotates. Current profit is 36 * $3 - 9 * $8 = $36. -10. 1 board and 0 wait, the wheel rotates. Current profit is 37 * $3 - 10 * $8 = $31. -The highest profit was $36 after rotating the wheel 9 times. --
Constraints:
diff --git a/problems/maximum-repeating-substring/README.md b/problems/maximum-repeating-substring/README.md index 96fe3070b..708d69560 100644 --- a/problems/maximum-repeating-substring/README.md +++ b/problems/maximum-repeating-substring/README.md @@ -53,9 +53,6 @@ [[String](../../tag/string/README.md)] [[String Matching](../../tag/string-matching/README.md)] -### Similar Questions - 1. [Detect Pattern of Length M Repeated K or More Times](../detect-pattern-of-length-m-repeated-k-or-more-times) (Easy) - ### HintsYou have n computers. You are given the integer n and a 0-indexed integer array batteries where the ith battery can run a computer for batteries[i] minutes. You are interested in running all n computers simultaneously using the given batteries.
Initially, you can insert at most one battery into each computer. After that and at any integer time moment, you can remove a battery from a computer and insert another battery any number of times. The inserted battery can be a totally new battery or a battery from another computer. You may assume that the removing and inserting processes take no time.
+ +Note that the batteries cannot be recharged.
+ +Return the maximum number of minutes you can run all the n computers simultaneously.
+
Example 1:
+
++Input: n = 2, batteries = [3,3,3] +Output: 4 +Explanation: +Initially, insert battery 0 into the first computer and battery 1 into the second computer. +After two minutes, remove battery 1 from the second computer and insert battery 2 instead. Note that battery 1 can still run for one minute. +At the end of the third minute, battery 0 is drained, and you need to remove it from the first computer and insert battery 1 instead. +By the end of the fourth minute, battery 1 is also drained, and the first computer is no longer running. +We can run the two computers simultaneously for at most 4 minutes, so we return 4. + ++ +
Example 2:
+
++Input: n = 2, batteries = [1,1,1,1] +Output: 2 +Explanation: +Initially, insert battery 0 into the first computer and battery 2 into the second computer. +After one minute, battery 0 and battery 2 are drained so you need to remove them and insert battery 1 into the first computer and battery 3 into the second computer. +After another minute, battery 1 and battery 3 are also drained so the first and second computers are no longer running. +We can run the two computers simultaneously for at most 2 minutes, so we return 2. ++ +
+
Constraints:
+ +1 <= n <= batteries.length <= 1051 <= batteries[i] <= 109Example 4:
- --Input: root = [2,1,3] -Output: 6 -- -
Example 5:
- --Input: root = [5,4,8,3,null,6,3] -Output: 7 --
Constraints:
diff --git a/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md b/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md index bc2d40939..f29094169 100644 --- a/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md +++ b/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../knight-probability-in-chessboard "Knight Probability in Chessboard") diff --git a/problems/maximum-twin-sum-of-a-linked-list/README.md b/problems/maximum-twin-sum-of-a-linked-list/README.md new file mode 100644 index 000000000..03df5b91f --- /dev/null +++ b/problems/maximum-twin-sum-of-a-linked-list/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../capitalize-the-title "Capitalize the Title") + +[Next >](../longest-palindrome-by-concatenating-two-letter-words "Longest Palindrome by Concatenating Two Letter Words") + +## [2130. Maximum Twin Sum of a Linked List (Medium)](https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list "链表最大孪生和") + +In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / 2) - 1.
n = 4, then node 0 is the twin of node 3, and node 1 is the twin of node 2. These are the only nodes with twins for n = 4.The twin sum is defined as the sum of a node and its twin.
+ +Given the head of a linked list with even length, return the maximum twin sum of the linked list.
+
Example 1:
+
++Input: head = [5,4,2,1] +Output: 6 +Explanation: +Nodes 0 and 1 are the twins of nodes 3 and 2, respectively. All have twin sum = 6. +There are no other nodes with twins in the linked list. +Thus, the maximum twin sum of the linked list is 6. ++ +
Example 2:
+
++Input: head = [4,2,2,3] +Output: 7 +Explanation: +The nodes with twins present in this linked list are: +- Node 0 is the twin of node 3 having a twin sum of 4 + 3 = 7. +- Node 1 is the twin of node 2 having a twin sum of 2 + 2 = 4. +Thus, the maximum twin sum of the linked list is max(7, 4) = 7. ++ +
Example 3:
+
++Input: head = [1,100000] +Output: 100001 +Explanation: +There is only one node with a twin in the linked list having twin sum of 1 + 100000 = 100001. ++ +
+
Constraints:
+ +[2, 105].1 <= Node.val <= 105Example 4:
- --Input: arr = [9,7,8,7,7,8,4,4,6,8,8,7,6,8,8,9,2,6,0,0,1,10,8,6,3,3,5,1,10,9,0,7,10,0,10,4,1,10,6,9,3,6,0,0,2,7,0,6,7,2,9,7,7,3,0,1,6,1,10,3] -Output: 5.27778 -- -
Example 5:
- --Input: arr = [4,8,4,10,0,7,1,3,7,8,8,3,4,1,6,2,1,1,8,0,9,8,0,3,9,10,3,10,1,10,7,3,2,1,4,9,10,7,6,4,0,8,5,1,2,1,6,2,5,0,7,10,9,10,3,7,10,5,8,5,7,6,7,6,10,9,5,10,5,5,7,2,10,7,7,8,2,0,1,1] -Output: 5.29167 --
Constraints:
diff --git a/problems/meeting-rooms-ii/README.md b/problems/meeting-rooms-ii/README.md index e08daae7c..03636b0e5 100644 --- a/problems/meeting-rooms-ii/README.md +++ b/problems/meeting-rooms-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../meeting-rooms "Meeting Rooms") @@ -28,9 +28,9 @@NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.
### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/merge-bsts-to-create-single-bst/README.md b/problems/merge-bsts-to-create-single-bst/README.md index 63d8f9678..f8271915c 100644 --- a/problems/merge-bsts-to-create-single-bst/README.md +++ b/problems/merge-bsts-to-create-single-bst/README.md @@ -65,14 +65,6 @@ The resulting tree is shown above. This is the only valid operation that can be Explanation: It is impossible to perform any operations. -Example 4:
-
--Input: trees = [[2,1,3]] -Output: [2,1,3] -Explanation: There is only one tree, and it is already a valid BST, so return its root. --
Constraints:
diff --git a/problems/merge-in-between-linked-lists/README.md b/problems/merge-in-between-linked-lists/README.md index 246908775..2206ccda2 100644 --- a/problems/merge-in-between-linked-lists/README.md +++ b/problems/merge-in-between-linked-lists/README.md @@ -15,7 +15,7 @@Remove list1's nodes from the ath node to the bth node, and put list2 in their place.
The blue edges and nodes in the following figure incidate the result:
+The blue edges and nodes in the following figure indicate the result:
Build the result list and return its head.
diff --git a/problems/merge-intervals/README.md b/problems/merge-intervals/README.md index d474da066..9a94b715c 100644 --- a/problems/merge-intervals/README.md +++ b/problems/merge-intervals/README.md @@ -53,3 +53,4 @@ 1. [Employee Free Time](../employee-free-time) (Hard) 1. [Partition Labels](../partition-labels) (Medium) 1. [Interval List Intersections](../interval-list-intersections) (Medium) + 1. [Amount of New Area Painted Each Day](../amount-of-new-area-painted-each-day) (Hard) diff --git a/problems/merge-strings-alternately/README.md b/problems/merge-strings-alternately/README.md index fa3b9c32b..27cb88935 100644 --- a/problems/merge-strings-alternately/README.md +++ b/problems/merge-strings-alternately/README.md @@ -61,6 +61,9 @@ merged: a p b q c d [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Zigzag Iterator](../zigzag-iterator) (Medium) + ### HintsInput: triplets = [[2,5,3],[1,8,4],[1,7,5]], target = [2,7,5] Output: true -Explanation: Perform the following operations: +Explanation: Perform the following operations: - Choose the first and last triplets [[2,5,3],[1,8,4],[1,7,5]]. Update the last triplet to be [max(2,1), max(5,7), max(3,5)] = [2,7,5]. triplets = [[2,5,3],[1,8,4],[2,7,5]] The target triplet [2,7,5] is now an element of triplets.@@ -39,9 +39,9 @@ The target triplet [2,7,5] is now an element of triplets.
Example 2:
-Input: triplets = [[1,3,4],[2,5,8]], target = [2,5,8] -Output: true -Explanation: The target triplet [2,5,8] is already an element of triplets. +Input: triplets = [[3,4,5],[4,5,6]], target = [3,2,5] +Output: false +Explanation: It is impossible to have [3,2,5] as an element because there is no 2 in any of the triplets.
Example 3:
@@ -55,14 +55,6 @@ The target triplet [2,7,5] is now an element of triplets. The target triplet [5,5,5] is now an element of triplets. -Example 4:
- --Input: triplets = [[3,4,5],[4,5,6]], target = [3,2,5] -Output: false -Explanation: It is impossible to have [3,2,5] as an element because there is no 2 in any of the triplets. --
Constraints:
diff --git a/problems/min-cost-to-connect-all-points/README.md b/problems/min-cost-to-connect-all-points/README.md index 6ad6e59f7..7cb2c19ad 100644 --- a/problems/min-cost-to-connect-all-points/README.md +++ b/problems/min-cost-to-connect-all-points/README.md @@ -11,22 +11,20 @@ ## [1584. Min Cost to Connect All Points (Medium)](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") -You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].
You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].
The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val.
The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val.
Return the minimum cost to make all points connected. All points are connected if there is exactly one simple path between any two points.
+Return the minimum cost to make all points connected. All points are connected if there is exactly one simple path between any two points.
Example 1:
- -
Input: points = [[0,0],[2,2],[3,10],[5,2],[7,0]] Output: 20 -Explanation: -@@ -38,41 +36,23 @@ Notice that there is a unique path between every pair of points. Output: 18 -+Explanation: +
We can connect the points as shown above to get the minimum cost of 20. Notice that there is a unique path between every pair of points.
Example 3:
- --Input: points = [[0,0],[1,1],[1,0],[-1,1]] -Output: 4 -- -
Example 4:
- --Input: points = [[-1000000,-1000000],[1000000,1000000]] -Output: 4000000 -- -
Example 5:
- --Input: points = [[0,0]] -Output: 0 --
Constraints:
1 <= points.length <= 1000-106 <= xi, yi <= 106-106 <= xi, yi <= 106(xi, yi) are distinct.Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.
Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.
Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows
a, b are from arra < bb - a equals to the minimum absolute difference of any two elements in arrb - a equals to the minimum absolute difference of any two elements in arr@@ -47,14 +47,17 @@
Constraints:
2 <= arr.length <= 10^5-10^6 <= arr[i] <= 10^62 <= arr.length <= 105-106 <= arr[i] <= 106Example 3:
- --Input: s = "()" -Output: 0 -- -
Example 4:
- -
-Input: s = "()))(("
-Output: 4
-
-
Constraints:
diff --git a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md index 94852b978..2f7a8dce0 100644 --- a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md +++ b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md @@ -50,10 +50,14 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Similar Questions + 1. [Minimum Swaps to Group All 1's Together](../minimum-swaps-to-group-all-1s-together) (Medium) + 1. [Minimum Number of Operations to Make Array Continuous](../minimum-number-of-operations-to-make-array-continuous) (Hard) ### Hints
Example 1:
-
+
Input: points = [[1,2],[2,1],[1,0],[0,1]] Output: 2.00000 @@ -27,7 +27,7 @@
Example 2:
-
+
Input: points = [[0,1],[2,1],[1,1],[1,0],[2,0]] Output: 1.00000 @@ -35,21 +35,13 @@
Example 3:
-
+
Input: points = [[0,3],[1,2],[3,1],[1,3],[2,1]] Output: 0 Explanation: There is no possible rectangle to form from these points.-
Example 4:
-
--Input: points = [[3,1],[1,1],[0,1],[2,1],[3,3],[3,2],[0,2],[2,3]] -Output: 2.00000 -Explanation: The minimum area rectangle occurs at [2,1],[2,3],[3,3],[3,1], with an area of 2. --
Constraints:
@@ -61,6 +53,6 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md b/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md new file mode 100644 index 000000000..49d80e975 --- /dev/null +++ b/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../minimum-number-of-buckets-required-to-collect-rainwater-from-houses "Minimum Number of Buckets Required to Collect Rainwater from Houses") + +[Next >](../count-fertile-pyramids-in-a-land "Count Fertile Pyramids in a Land") + +## [2087. Minimum Cost Homecoming of a Robot in a Grid (Medium)](https://leetcode.com/problems/minimum-cost-homecoming-of-a-robot-in-a-grid "网格图中机器人回家的最小代价") + +There is an m x n grid, where (0, 0) is the top-left cell and (m - 1, n - 1) is the bottom-right cell. You are given an integer array startPos where startPos = [startrow, startcol] indicates that initially, a robot is at the cell (startrow, startcol). You are also given an integer array homePos where homePos = [homerow, homecol] indicates that its home is at the cell (homerow, homecol).
The robot needs to go to its home. It can move one cell in four directions: left, right, up, or down, and it can not move outside the boundary. Every move incurs some cost. You are further given two 0-indexed integer arrays: rowCosts of length m and colCosts of length n.
r, then this move costs rowCosts[r].c, then this move costs colCosts[c].Return the minimum total cost for this robot to return home.
+ ++
Example 1:
+
++Input: startPos = [1, 0], homePos = [2, 3], rowCosts = [5, 4, 3], colCosts = [8, 2, 6, 7] +Output: 18 +Explanation: One optimal path is that: +Starting from (1, 0) +-> It goes down to (2, 0). This move costs rowCosts[2] = 3. +-> It goes right to (2, 1). This move costs colCosts[1] = 2. +-> It goes right to (2, 2). This move costs colCosts[2] = 6. +-> It goes right to (2, 3). This move costs colCosts[3] = 7. +The total cost is 3 + 2 + 6 + 7 = 18+ +
Example 2:
+ ++Input: startPos = [0, 0], homePos = [0, 0], rowCosts = [5], colCosts = [26] +Output: 0 +Explanation: The robot is already at its home. Since no moves occur, the total cost is 0. ++ +
+
Constraints:
+ +m == rowCosts.lengthn == colCosts.length1 <= m, n <= 1050 <= rowCosts[r], colCosts[c] <= 104startPos.length == 2homePos.length == 20 <= startrow, homerow < m0 <= startcol, homecol < nA shop is selling candies at a discount. For every two candies sold, the shop gives a third candy for free.
+ +The customer can choose any candy to take away for free as long as the cost of the chosen candy is less than or equal to the minimum cost of the two candies bought.
+ +4 candies with costs 1, 2, 3, and 4, and the customer buys candies with costs 2 and 3, they can take the candy with cost 1 for free, but not the candy with cost 4.Given a 0-indexed integer array cost, where cost[i] denotes the cost of the ith candy, return the minimum cost of buying all the candies.
+
Example 1:
+ ++Input: cost = [1,2,3] +Output: 5 +Explanation: We buy the candies with costs 2 and 3, and take the candy with cost 1 for free. +The total cost of buying all candies is 2 + 3 = 5. This is the only way we can buy the candies. +Note that we cannot buy candies with costs 1 and 3, and then take the candy with cost 2 for free. +The cost of the free candy has to be less than or equal to the minimum cost of the purchased candies. ++ +
Example 2:
+ ++Input: cost = [6,5,7,9,2,2] +Output: 23 +Explanation: The way in which we can get the minimum cost is described below: +- Buy candies with costs 9 and 7 +- Take the candy with cost 6 for free +- We buy candies with costs 5 and 2 +- Take the last remaining candy with cost 2 for free +Hence, the minimum cost to buy all candies is 9 + 7 + 5 + 2 = 23. ++ +
Example 3:
+ ++Input: cost = [5,5] +Output: 10 +Explanation: Since there are only 2 candies, we buy both of them. There is not a third candy we can take for free. +Hence, the minimum cost to buy all candies is 5 + 5 = 10. ++ +
+
Constraints:
+ +1 <= cost.length <= 1001 <= cost[i] <= 100A generic microwave supports cooking times for:
+ +1 second.99 minutes and 99 seconds.To set the cooking time, you push at most four digits. The microwave normalizes what you push as four digits by prepending zeroes. It interprets the first two digits as the minutes and the last two digits as the seconds. It then adds them up as the cooking time. For example,
+ +9 5 4 (three digits). It is normalized as 0954 and interpreted as 9 minutes and 54 seconds.0 0 0 8 (four digits). It is interpreted as 0 minutes and 8 seconds.8 0 9 0. It is interpreted as 80 minutes and 90 seconds.8 1 3 0. It is interpreted as 81 minutes and 30 seconds.You are given integers startAt, moveCost, pushCost, and targetSeconds. Initially, your finger is on the digit startAt. Moving the finger above any specific digit costs moveCost units of fatigue. Pushing the digit below the finger once costs pushCost units of fatigue.
There can be multiple ways to set the microwave to cook for targetSeconds seconds but you are interested in the way with the minimum cost.
Return the minimum cost to set targetSeconds seconds of cooking time.
Remember that one minute consists of 60 seconds.
+
Example 1:
+
++Input: startAt = 1, moveCost = 2, pushCost = 1, targetSeconds = 600 +Output: 6 +Explanation: The following are the possible ways to set the cooking time. +- 1 0 0 0, interpreted as 10 minutes and 0 seconds. + The finger is already on digit 1, pushes 1 (with cost 1), moves to 0 (with cost 2), pushes 0 (with cost 1), pushes 0 (with cost 1), and pushes 0 (with cost 1). + The cost is: 1 + 2 + 1 + 1 + 1 = 6. This is the minimum cost. +- 0 9 6 0, interpreted as 9 minutes and 60 seconds. That is also 600 seconds. + The finger moves to 0 (with cost 2), pushes 0 (with cost 1), moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1). + The cost is: 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 = 12. +- 9 6 0, normalized as 0960 and interpreted as 9 minutes and 60 seconds. + The finger moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1). + The cost is: 2 + 1 + 2 + 1 + 2 + 1 = 9. ++ +
Example 2:
+
++Input: startAt = 0, moveCost = 1, pushCost = 2, targetSeconds = 76 +Output: 6 +Explanation: The optimal way is to push two digits: 7 6, interpreted as 76 seconds. +The finger moves to 7 (with cost 1), pushes 7 (with cost 2), moves to 6 (with cost 1), and pushes 6 (with cost 2). The total cost is: 1 + 2 + 1 + 2 = 6 +Note other possible ways are 0076, 076, 0116, and 116, but none of them produces the minimum cost. ++ +
+
Constraints:
+ +0 <= startAt <= 91 <= moveCost, pushCost <= 1051 <= targetSeconds <= 6039Given an array nums, you are allowed to choose one element of nums and change it by any value in one move.
You are given an integer array nums. In one move, you can choose one element of nums and change it by any value.
Return the minimum difference between the largest and smallest value of nums after perfoming at most 3 moves.
Return the minimum difference between the largest and smallest value of nums after performing at most three moves.
Example 1:
@@ -22,7 +22,8 @@ Input: nums = [5,3,2,4] Output: 0 Explanation: Change the array [5,3,2,4] to [2,2,2,2]. -The difference between the maximum and minimum is 2-2 = 0. +The difference between the maximum and minimum is 2-2 = 0. +Example 2:
@@ -33,26 +34,12 @@ The difference between the maximum and minimum is 2-2 = 0. The difference between the maximum and minimum is 1-0 = 1. -Example 3:
- --Input: nums = [6,6,0,1,1,4,6] -Output: 2 -- -
Example 4:
- --Input: nums = [1,5,6,14,15] -Output: 1 --
Constraints:
1 <= nums.length <= 10^5-10^9 <= nums[i] <= 10^91 <= nums.length <= 105-109 <= nums[i] <= 109You are given a 0-indexed integer array nums consisting of 3 * n elements.
You are allowed to remove any subsequence of elements of size exactly n from nums. The remaining 2 * n elements will be divided into two equal parts:
n elements belonging to the first part and their sum is sumfirst.n elements belonging to the second part and their sum is sumsecond.The difference in sums of the two parts is denoted as sumfirst - sumsecond.
sumfirst = 3 and sumsecond = 2, their difference is 1.sumfirst = 2 and sumsecond = 3, their difference is -1.Return the minimum difference possible between the sums of the two parts after the removal of n elements.
+
Example 1:
+ ++Input: nums = [3,1,2] +Output: -1 +Explanation: Here, nums has 3 elements, so n = 1. +Thus we have to remove 1 element from nums and divide the array into two equal parts. +- If we remove nums[0] = 3, the array will be [1,2]. The difference in sums of the two parts will be 1 - 2 = -1. +- If we remove nums[1] = 1, the array will be [3,2]. The difference in sums of the two parts will be 3 - 2 = 1. +- If we remove nums[2] = 2, the array will be [3,1]. The difference in sums of the two parts will be 3 - 1 = 2. +The minimum difference between sums of the two parts is min(-1,1,2) = -1. ++ +
Example 2:
+ ++Input: nums = [7,9,5,8,1,3] +Output: 1 +Explanation: Here n = 2. So we must remove 2 elements and divide the remaining array into two parts containing two elements each. +If we remove nums[2] = 5 and nums[3] = 8, the resultant array will be [7,9,1,3]. The difference in sums will be (7+9) - (1+3) = 12. +To obtain the minimum difference, we should remove nums[1] = 9 and nums[4] = 1. The resultant array becomes [7,5,8,3]. The difference in sums of the two parts is (7+5) - (8+3) = 1. +It can be shown that it is not possible to obtain a difference smaller than 1. ++ +
+
Constraints:
+ +nums.length == 3 * n1 <= n <= 1051 <= nums[i] <= 105You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the i-th job, you have to finish all the jobs j where 0 <= j < i).
You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the ith job, you have to finish all the jobs j where 0 <= j < i).
You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done in that day.
You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done on that day.
Given an array of integers jobDifficulty and an integer d. The difficulty of the i-th job is jobDifficulty[i].
You are given an integer array jobDifficulty and an integer d. The difficulty of the ith job is jobDifficulty[i].
Return the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.
+Return the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.
Example 1:
@@ -46,20 +46,6 @@ The difficulty of the schedule = 6 + 1 = 7 Explanation: The schedule is one job per day. total difficulty will be 3. -Example 4:
- --Input: jobDifficulty = [7,1,7,1,7,1], d = 3 -Output: 15 -- -
Example 5:
- --Input: jobDifficulty = [11,111,22,222,33,333,44,444], d = 6 -Output: 843 --
Constraints:
diff --git a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md index b519e4090..48841f1ad 100644 --- a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md +++ b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md @@ -30,8 +30,7 @@Input: word = "CAKE" Output: 3 -Explanation: -Using two fingers, one optimal way to type "CAKE" is: +Explanation: Using two fingers, one optimal way to type "CAKE" is: Finger 1 on letter 'C' -> cost = 0 Finger 1 on letter 'A' -> cost = Distance from letter 'C' to letter 'A' = 2 Finger 2 on letter 'K' -> cost = 0 @@ -44,8 +43,7 @@ Total distance = 3-Input: word = "HAPPY" Output: 6 -Explanation: -Using two fingers, one optimal way to type "HAPPY" is: +Explanation: Using two fingers, one optimal way to type "HAPPY" is: Finger 1 on letter 'H' -> cost = 0 Finger 1 on letter 'A' -> cost = Distance from letter 'H' to letter 'A' = 2 Finger 2 on letter 'P' -> cost = 0 @@ -54,20 +52,6 @@ Finger 1 on letter 'Y' -> cost = Distance from letter 'A' to Total distance = 6-Example 3:
- --Input: word = "NEW" -Output: 3 -- -Example 4:
- --Input: word = "YEAR" -Output: 7 --
Constraints:
diff --git a/problems/minimum-domino-rotations-for-equal-row/README.md b/problems/minimum-domino-rotations-for-equal-row/README.md index 63b5a53a9..70e13dd34 100644 --- a/problems/minimum-domino-rotations-for-equal-row/README.md +++ b/problems/minimum-domino-rotations-for-equal-row/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../clumsy-factorial "Clumsy Factorial") @@ -49,5 +49,5 @@ In this case, it is not possible to rotate the dominoes to make one row of value ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/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 index dfbb7e274..1bad5bcd5 100644 --- 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 @@ -44,8 +44,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hintsdiff --git a/problems/minimum-falling-path-sum-ii/README.md b/problems/minimum-falling-path-sum-ii/README.md index d0c06f521..446fbe15c 100644 --- a/problems/minimum-falling-path-sum-ii/README.md +++ b/problems/minimum-falling-path-sum-ii/README.md @@ -50,6 +50,9 @@ The falling path with the smallest sum is [1,5,7], so the answer is 13 [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Minimum Falling Path Sum](../minimum-falling-path-sum) (Medium) + ### HintsHint 1
diff --git a/problems/minimum-falling-path-sum/README.md b/problems/minimum-falling-path-sum/README.md index 9e7856ffb..cbd4580c6 100644 --- a/problems/minimum-falling-path-sum/README.md +++ b/problems/minimum-falling-path-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-subarrays-with-sum "Binary Subarrays With Sum") diff --git a/problems/minimum-genetic-mutation/README.md b/problems/minimum-genetic-mutation/README.md index 906685cc7..464225609 100644 --- a/problems/minimum-genetic-mutation/README.md +++ b/problems/minimum-genetic-mutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-oone-data-structure "All O`one Data Structure") diff --git a/problems/minimum-incompatibility/README.md b/problems/minimum-incompatibility/README.md index cb789c363..8cce8ee4d 100644 --- a/problems/minimum-incompatibility/README.md +++ b/problems/minimum-incompatibility/README.md @@ -56,9 +56,9 @@ The incompatibility is (2-1) + (3-2) + (8-6) + (3-1) = 6. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Hints diff --git a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md index db3e86945..4dea8e463 100644 --- a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md +++ b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md @@ -42,26 +42,12 @@ Explanation: Inserting 5 characters the string becomes "leetcodocteel".
Example 4:
- --Input: s = "g" -Output: 0 -- -
Example 5:
- --Input: s = "no" -Output: 1 --
Constraints:
1 <= s.length <= 500s are lower case English letters.s consists of lowercase English letters.Given a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if:
'(' must have a corresponding two consecutive right parenthesis '))'.'(' must go before the corresponding two consecutive right parenthesis '))'.'(' must have a corresponding two consecutive right parenthesis '))'.'(' must go before the corresponding two consecutive right parenthesis '))'.In other words, we treat '(' as openning parenthesis and '))' as closing parenthesis.
In other words, we treat '(' as an opening parenthesis and '))' as a closing parenthesis.
For example, "())", "())(())))" and "(())())))" are balanced, ")()", "()))" and "(()))" are not balanced.
"())", "())(())))" and "(())())))" are balanced, ")()", "()))" and "(()))" are not balanced.You can insert the characters '(' and ')' at any position of the string to balance it if needed.
Example 4:
- -
-Input: s = "(((((("
-Output: 12
-Explanation: Add 12 ')' to balance the string.
-
-
-Example 5:
- -
-Input: s = ")))))))"
-Output: 5
-Explanation: Add 4 '(' at the beginning of the string and one ')' at the end. The string becomes "(((())))))))".
-
-
Constraints:
1 <= s.length <= 10^51 <= s.length <= 105s consists of '(' and ')' only.
Example 1:
-
+
Input: grid = [["#","#","#","#","#","#"],
["#","T","#","#","#","#"],
- ["#",".",".","B",".","#"],
- ["#",".","#","#",".","#"],
- ["#",".",".",".","S","#"],
- ["#","#","#","#","#","#"]]
+ ["#",".",".","B",".","#"],
+ ["#",".","#","#",".","#"],
+ ["#",".",".",".","S","#"],
+ ["#","#","#","#","#","#"]]
Output: 3
-Explanation: We return only the number of times the box is pushed.
+Explanation: We return only the number of times the box is pushed.
Example 2:
Input: grid = [["#","#","#","#","#","#"],
["#","T","#","#","#","#"],
- ["#",".",".","B",".","#"],
- ["#","#","#","#",".","#"],
- ["#",".",".",".","S","#"],
- ["#","#","#","#","#","#"]]
+ ["#",".",".","B",".","#"],
+ ["#","#","#","#",".","#"],
+ ["#",".",".",".","S","#"],
+ ["#","#","#","#","#","#"]]
Output: -1
@@ -57,22 +57,13 @@
Input: grid = [["#","#","#","#","#","#"], - ["#","T",".",".","#","#"], - ["#",".","#","B",".","#"], - ["#",".",".",".",".","#"], - ["#",".",".",".","S","#"], - ["#","#","#","#","#","#"]] + ["#","T",".",".","#","#"], + ["#",".","#","B",".","#"], + ["#",".",".",".",".","#"], + ["#",".",".",".","S","#"], + ["#","#","#","#","#","#"]] Output: 5 -Explanation: push the box down, left, left, up and up. -- -
Example 4:
- --Input: grid = [["#","#","#","#","#","#","#"], - ["#","S","#",".","B","T","#"], - ["#","#","#","#","#","#","#"]] -Output: -1 +Explanation: push the box down, left, left, up and up.
diff --git a/problems/minimum-moves-to-reach-target-score/README.md b/problems/minimum-moves-to-reach-target-score/README.md new file mode 100644 index 000000000..03f9395f4 --- /dev/null +++ b/problems/minimum-moves-to-reach-target-score/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../divide-a-string-into-groups-of-size-k "Divide a String Into Groups of Size k") + +[Next >](../solving-questions-with-brainpower "Solving Questions With Brainpower") + +## [2139. Minimum Moves to Reach Target Score (Medium)](https://leetcode.com/problems/minimum-moves-to-reach-target-score "得到目标值的最少行动次数") + +
You are playing a game with integers. You start with the integer 1 and you want to reach the integer target.
In one move, you can either:
+ +x = x + 1).x = 2 * x).You can use the increment operation any number of times, however, you can only use the double operation at most maxDoubles times.
Given the two integers target and maxDoubles, return the minimum number of moves needed to reach target starting with 1.
+
Example 1:
+ ++Input: target = 5, maxDoubles = 0 +Output: 4 +Explanation: Keep incrementing by 1 until you reach target. ++ +
Example 2:
+ ++Input: target = 19, maxDoubles = 2 +Output: 7 +Explanation: Initially, x = 1 +Increment 3 times so x = 4 +Double once so x = 8 +Increment once so x = 9 +Double again so x = 18 +Increment once so x = 19 ++ +
Example 3:
+ ++Input: target = 10, maxDoubles = 4 +Output: 4 +Explanation: Initially, x = 1 +Increment once so x = 2 +Double once so x = 4 +Increment once so x = 5 +Double again so x = 10 ++ +
+
Constraints:
+ +1 <= target <= 1090 <= maxDoubles <= 100You are given a 0-indexed string street. Each character in street is either 'H' representing a house or '.' representing an empty space.
You can place buckets on the empty spaces to collect rainwater that falls from the adjacent houses. The rainwater from a house at index i is collected if a bucket is placed at index i - 1 and/or index i + 1. A single bucket, if placed adjacent to two houses, can collect the rainwater from both houses.
Return the minimum number of buckets needed so that for every house, there is at least one bucket collecting rainwater from it, or -1 if it is impossible.
+
Example 1:
+ +
+Input: street = "H..H"
+Output: 2
+Explanation:
+We can put buckets at index 1 and index 2.
+"H..H" -> "HBBH" ('B' denotes where a bucket is placed).
+The house at index 0 has a bucket to its right, and the house at index 3 has a bucket to its left.
+Thus, for every house, there is at least one bucket collecting rainwater from it.
+
+
+Example 2:
+ +
+Input: street = ".H.H."
+Output: 1
+Explanation:
+We can put a bucket at index 2.
+".H.H." -> ".HBH." ('B' denotes where a bucket is placed).
+The house at index 1 has a bucket to its right, and the house at index 3 has a bucket to its left.
+Thus, for every house, there is at least one bucket collecting rainwater from it.
+
+
+Example 3:
+ ++Input: street = ".HHH." +Output: -1 +Explanation: +There is no empty space to place a bucket to collect the rainwater from the house at index 2. +Thus, it is impossible to collect the rainwater from all the houses. ++ +
+
Constraints:
+ +1 <= street.length <= 105street[i] is either'H' or '.'.Given a 2D grid consisting of 1s (land) and 0s (water). An island is a maximal 4-directionally (horizontal or vertical) connected group of 1s.
You are given an m x n binary grid grid where 1 represents land and 0 represents water. An island is a maximal 4-directionally (horizontal or vertical) connected group of 1's.
The grid is said to be connected if we have exactly one island, otherwise is said disconnected.
+The grid is said to be connected if we have exactly one island, otherwise is said disconnected.
In one day, we are allowed to change any single land cell (1) into a water cell (0).
Return the minimum number of days to disconnect the grid.
+Return the minimum number of days to disconnect the grid.
Example 1:
- -
Input: grid = [[0,1,1,0],[0,1,1,0],[0,0,0,0]] + Output: 2 Explanation: We need at least 2 days to get a disconnected grid. Change land grid[1][1] and grid[0][2] to water and get 2 disconnected island.
Example 2:
- +
Input: grid = [[1,1]] Output: 2 -Explanation: Grid of full water is also disconnected ([[1,1]] -> [[0,0]]), 0 islands. -- -
Example 3:
- --Input: grid = [[1,0,1,0]] -Output: 0 -- -
Example 4:
- --Input: grid = [[1,1,0,1,1], - [1,1,1,1,1], - [1,1,0,1,1], - [1,1,0,1,1]] -Output: 1 -- -
Example 5:
- --Input: grid = [[1,1,0,1,1], - [1,1,1,1,1], - [1,1,0,1,1], - [1,1,1,1,1]] -Output: 2 +Explanation: Grid of full water is also disconnected ([[1,1]] -> [[0,0]]), 0 islands.
Constraints:
1 <= grid.length, grid[i].length <= 30grid[i][j] is 0 or 1.m == grid.lengthn == grid[i].length1 <= m, n <= 30grid[i][j] is either 0 or 1.2 then you can eat n / 2 oranges.3 then you can eat 2 * (n / 3) oranges.n is divisible by 2 then you can eat n / 2 oranges.n is divisible by 3 then you can eat 2 * (n / 3) oranges.You can only choose one of the actions per day.
-Return the minimum number of days to eat n oranges.
Given the integer n, return the minimum number of days to eat n oranges.
Example 1:
@@ -49,20 +49,6 @@ Day 3: Eat the last orange 1 - 1 = 0. You need at least 3 days to eat the 6 oranges. -Example 3:
- --Input: n = 1 -Output: 1 -- -
Example 4:
- --Input: n = 56 -Output: 6 --
Constraints:
diff --git a/problems/minimum-number-of-days-to-make-m-bouquets/README.md b/problems/minimum-number-of-days-to-make-m-bouquets/README.md index 79478879e..23c7493b3 100644 --- a/problems/minimum-number-of-days-to-make-m-bouquets/README.md +++ b/problems/minimum-number-of-days-to-make-m-bouquets/README.md @@ -11,13 +11,13 @@ ## [1482. Minimum Number of Days to Make m Bouquets (Medium)](https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets "制作 m 束花所需的最少天数") -Given an integer array bloomDay, an integer m and an integer k.
You are given an integer array bloomDay, an integer m and an integer k.
We need to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.
You want to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.
The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.
The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.
Return the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.
Return the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.
Example 1:
@@ -25,7 +25,7 @@Input: bloomDay = [1,10,3,10,2], m = 3, k = 1 Output: 3 -Explanation: Let's see what happened in the first three days. x means flower bloomed and _ means flower didn't bloom in the garden. +Explanation: Let us see what happened in the first three days. x means flower bloomed and _ means flower did not bloom in the garden. We need 3 bouquets each should contain 1 flower. After day 1: [x, _, _, _, _] // we can only make one bouquet. After day 2: [x, _, _, _, x] // we can only make two bouquets. @@ -46,36 +46,21 @@ After day 3: [x, _, x, _, x] // we can make 3 bouquets. The answer is 3. Input: bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3 Output: 12 Explanation: We need 2 bouquets each should have 3 flowers. -Here's the garden after the 7 and 12 days: +Here is the garden after the 7 and 12 days: After day 7: [x, x, x, x, _, x, x] We can make one bouquet of the first three flowers that bloomed. We cannot make another bouquet from the last three flowers that bloomed because they are not adjacent. After day 12: [x, x, x, x, x, x, x] It is obvious that we can make two bouquets in different ways.-
Example 4:
- --Input: bloomDay = [1000000000,1000000000], m = 1, k = 1 -Output: 1000000000 -Explanation: You need to wait 1000000000 days to have a flower ready for a bouquet. -- -
Example 5:
- --Input: bloomDay = [1,10,2,9,3,8,4,7,5,6], m = 4, k = 2 -Output: 9 --
Constraints:
bloomDay.length == n1 <= n <= 10^51 <= bloomDay[i] <= 10^91 <= m <= 10^61 <= n <= 1051 <= bloomDay[i] <= 1091 <= m <= 1061 <= k <= nInput: mat = [[0]] Output: 0 -Explanation: Given matrix is a zero matrix. We don't need to change it. +Explanation: Given matrix is a zero matrix. We do not need to change it.
Example 3:
--Input: mat = [[1,1,1],[1,0,1],[0,0,0]] -Output: 6 -- -
Example 4:
-Input: mat = [[1,0,0],[1,0,0]] Output: -1 -Explanation: Given matrix can't be a zero matrix +Explanation: Given matrix cannot be a zero matrix.
@@ -67,6 +60,10 @@ [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Minimum Operations to Remove Adjacent Ones in Matrix](../minimum-operations-to-remove-adjacent-ones-in-matrix) (Hard) + 1. [Remove All Ones With Row and Column Flips](../remove-all-ones-with-row-and-column-flips) (Medium) + ### Hints
Given an array of positive integers target and an array initial of same size with all zeros.
You are given an integer array target. You have an integer array initial of the same size as target with all elements initially zeros.
Return the minimum number of operations to form a target array from initial if you are allowed to do the following operation:
In one operation you can choose any subarray from initial and increment each value by one.
Return the minimum number of operations to form a target array from initial.
The test cases are generated so that the answer fits in a 32-bit integer.
-initial and increment each value by one.
Example 1:
Input: target = [1,2,3,2,1] Output: 3 -Explanation: We need at least 3 operations to form the target array from the initial array. -[0,0,0,0,0] increment 1 from index 0 to 4 (inclusive). -[1,1,1,1,1] increment 1 from index 1 to 3 (inclusive). -[1,2,2,2,1] increment 1 at index 2. +Explanation: We need at least 3 operations to form the target array from the initial array. +[0,0,0,0,0] increment 1 from index 0 to 4 (inclusive). +[1,1,1,1,1] increment 1 from index 1 to 3 (inclusive). +[1,2,2,2,1] increment 1 at index 2. [1,2,3,2,1] target array is formed.@@ -37,7 +37,7 @@ The answer is guaranteed to fit within the range of a 32-bit signed integer.
Input: target = [3,1,1,2] Output: 4 -Explanation: (initial)[0,0,0,0] -> [1,1,1,1] -> [1,1,1,2] -> [2,1,1,2] -> [3,1,1,2] (target). +Explanation: [0,0,0,0] -> [1,1,1,1] -> [1,1,1,2] -> [2,1,1,2] -> [3,1,1,2]
Example 3:
@@ -45,23 +45,15 @@ The answer is guaranteed to fit within the range of a 32-bit signed integer.Input: target = [3,1,5,4,2] Output: 7 -Explanation: (initial)[0,0,0,0,0] -> [1,1,1,1,1] -> [2,1,1,1,1] -> [3,1,1,1,1] - -> [3,1,2,2,2] -> [3,1,3,3,2] -> [3,1,4,4,2] -> [3,1,5,4,2] (target). -- -
Example 4:
- --Input: target = [1,1,1,1] -Output: 1 +Explanation: [0,0,0,0,0] -> [1,1,1,1,1] -> [2,1,1,1,1] -> [3,1,1,1,1] -> [3,1,2,2,2] -> [3,1,3,3,2] -> [3,1,4,4,2] -> [3,1,5,4,2].
Constraints:
1 <= target.length <= 10^51 <= target[i] <= 10^51 <= target.length <= 1051 <= target[i] <= 105Example 3:
- --Input: s = "cdbea" -Output: 63- -
Example 4:
- --Input: s = "leetcodeleetcodeleetcode" -Output: 982157772 --
Constraints:
diff --git a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md index 3f34200f4..42d3cc5e1 100644 --- a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md +++ b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md @@ -50,6 +50,9 @@ [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Minimum Cost to Move Chips to The Same Position](../minimum-cost-to-move-chips-to-the-same-position) (Easy) + ### HintsExample 3:
- --Input: nums = [4,3,2,1,1,2,3,1] -Output: 4 -- -
Example 4:
- --Input: nums = [1,2,3,4,4,3,2,1] -Output: 1 --
Constraints:
diff --git a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md index 5038dbee9..22618114e 100644 --- a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md +++ b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md @@ -11,11 +11,11 @@ ## [1347. Minimum Number of Steps to Make Two Strings Anagram (Medium)](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram "制造字母异位词的最小步骤数") -Given two equal-size strings s and t. In one step you can choose any character of t and replace it with another character.
You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.
Return the minimum number of steps to make t an anagram of s.
Return the minimum number of steps to make t an anagram of s.
An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.
+An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.
Example 1:
@@ -42,27 +42,13 @@ Explanation: "anagram" and "mangaar" are anagrams. -Example 4:
- --Input: s = "xxyyzz", t = "xxyyzz" -Output: 0 -- -
Example 5:
- --Input: s = "friend", t = "family" -Output: 4 --
Constraints:
1 <= s.length <= 500001 <= s.length <= 5 * 104s.length == t.lengths and t contain lower-case English letters only.s and t consist of lowercase English letters only.Example 3:
- --Input: n = 7, ranges = [1,2,1,0,2,1,0,1] -Output: 3 -- -
Example 4:
- --Input: n = 8, ranges = [4,0,0,0,0,0,0,0,4] -Output: 2 -- -
Example 5:
- --Input: n = 8, ranges = [4,0,0,0,4,0,0,0,4] -Output: 1 --
Constraints:
@@ -73,9 +52,9 @@ Opening Only the second tap will water the whole garden [0,5] ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
You are given an integer array nums. You have an integer array arr of the same length with all values set to 0 initially. You also have the following modify function:
+You want to use the modify function to covert arr to nums using the minimum number of calls.
Your task is to form an integer array nums from an initial array of zeros arr that is the same size as nums.
Return the minimum number of function calls to make nums from arr.
Return the minimum number of function calls to make nums from arr.
The answer is guaranteed to fit in a 32-bit signed integer.
+The test cases are generated so that the answer fits in a 32-bit signed integer.
Example 1:
@@ -49,26 +49,12 @@ Total of operations: 2 + 1 = 3. Explanation: (initial)[0,0,0] -> [1,0,0] -> [1,0,1] -> [2,0,2] -> [2,1,2] -> [4,2,4] -> [4,2,5](nums). -Example 4:
- --Input: nums = [3,2,2,4] -Output: 7 -- -
Example 5:
- --Input: nums = [2,4,8,16] -Output: 8 --
Constraints:
1 <= nums.length <= 10^50 <= nums[i] <= 10^91 <= nums.length <= 1050 <= nums[i] <= 109
Example 1:
--Input: n = 0 -Output: 0 -- -
Example 2:
-Input: n = 3 Output: 2 Explanation: The binary representation of 3 is "11". -"11" -> "01" with the 2nd operation since the 0th bit is 1. -"01" -> "00" with the 1st operation. +"11" -> "01" with the 2nd operation since the 0th bit is 1. +"01" -> "00" with the 1st operation.-
Example 3:
+Example 2:
Input: n = 6 Output: 4 Explanation: The binary representation of 6 is "110". -"110" -> "010" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0. -"010" -> "011" with the 1st operation. -"011" -> "001" with the 2nd operation since the 0th bit is 1. -"001" -> "000" with the 1st operation. -- -
Example 4:
- --Input: n = 9 -Output: 14 -- -
Example 5:
- --Input: n = 333 -Output: 393 +"110" -> "010" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0. +"010" -> "011" with the 1st operation. +"011" -> "001" with the 2nd operation since the 0th bit is 1. +"001" -> "000" with the 1st operation.
@@ -72,9 +51,12 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Similar Questions + 1. [Minimum Number of Operations to Make Array Continuous](../minimum-number-of-operations-to-make-array-continuous) (Hard) ### Hints
You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:
You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:
If 0 <= x <= 1000, then for any index i in the array (0 <= i < nums.length), you can set x to any of the following:
Example 1:
--Input: nums = [1,3], start = 6, goal = 4 -Output: 2 -Explanation: -We can go from 6 → 7 → 4 with the following 2 operations. -- 6 ^ 1 = 7 -- 7 ^ 3 = 4 -- -
Example 2:
-Input: nums = [2,4,12], start = 2, goal = 12 Output: 2 -Explanation: -We can go from 2 → 14 → 12 with the following 2 operations. +Explanation: We can go from 2 → 14 → 12 with the following 2 operations. - 2 + 12 = 14 - 14 - 2 = 12-
Example 3:
+Example 2:
Input: nums = [3,5,7], start = 0, goal = -4 Output: 2 -Explanation: -We can go from 0 → 3 → -4 with the following 2 operations. +Explanation: We can go from 0 → 3 → -4 with the following 2 operations. - 0 + 3 = 3 - 3 - 7 = -4 Note that the last operation sets x out of the range 0 <= x <= 1000, which is valid.-
Example 4:
+Example 3:
Input: nums = [2,8,16], start = 0, goal = 1 Output: -1 -Explanation: -There is no way to convert 0 into 1.- -
Example 5:
- --Input: nums = [1], start = 0, goal = 3 -Output: 3 -Explanation: -We can go from 0 → 1 → 2 → 3 with the following 3 operations. -- 0 + 1 = 1 -- 1 + 1 = 2 -- 2 + 1 = 3 +Explanation: There is no way to convert 0 into 1.
diff --git a/problems/minimum-operations-to-make-the-array-alternating/README.md b/problems/minimum-operations-to-make-the-array-alternating/README.md new file mode 100644 index 000000000..8b1fec07d --- /dev/null +++ b/problems/minimum-operations-to-make-the-array-alternating/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../count-operations-to-obtain-zero "Count Operations to Obtain Zero") + +[Next >](../removing-minimum-number-of-magic-beans "Removing Minimum Number of Magic Beans") + +## [2170. Minimum Operations to Make the Array Alternating (Medium)](https://leetcode.com/problems/minimum-operations-to-make-the-array-alternating "使数组变成交替数组的最少操作数") + +
You are given a 0-indexed array nums consisting of n positive integers.
The array nums is called alternating if:
nums[i - 2] == nums[i], where 2 <= i <= n - 1.nums[i - 1] != nums[i], where 1 <= i <= n - 1.In one operation, you can choose an index i and change nums[i] into any positive integer.
Return the minimum number of operations required to make the array alternating.
+ ++
Example 1:
+ ++Input: nums = [3,1,3,2,4,3] +Output: 3 +Explanation: +One way to make the array alternating is by converting it to [3,1,3,1,3,1]. +The number of operations required in this case is 3. +It can be proven that it is not possible to make the array alternating in less than 3 operations. ++ +
Example 2:
+ ++Input: nums = [1,2,2,2,2] +Output: 2 +Explanation: +One way to make the array alternating is by converting it to [1,2,1,2,1]. +The number of operations required in this case is 2. +Note that the array cannot be converted to [2,2,2,2,2] because in this case nums[0] == nums[1] which violates the conditions of an alternating array. ++ +
+
Constraints:
+ +1 <= nums.length <= 1051 <= nums[i] <= 105You are given a 0-indexed array arr consisting of n positive integers, and a positive integer k.
The array arr is called K-increasing if arr[i-k] <= arr[i] holds for every index i, where k <= i <= n-1.
arr = [4, 1, 5, 2, 6, 2] is K-increasing for k = 2 because:
+ arr[0] <= arr[2] (4 <= 5)arr[1] <= arr[3] (1 <= 2)arr[2] <= arr[4] (5 <= 6)arr[3] <= arr[5] (2 <= 2)arr is not K-increasing for k = 1 (because arr[0] > arr[1]) or k = 3 (because arr[0] > arr[3]).In one operation, you can choose an index i and change arr[i] into any positive integer.
Return the minimum number of operations required to make the array K-increasing for the given k.
+
Example 1:
+ ++Input: arr = [5,4,3,2,1], k = 1 +Output: 4 +Explanation: +For k = 1, the resultant array has to be non-decreasing. +Some of the K-increasing arrays that can be formed are [5,6,7,8,9], [1,1,1,1,1], [2,2,3,4,4]. All of them require 4 operations. +It is suboptimal to change the array to, for example, [6,7,8,9,10] because it would take 5 operations. +It can be shown that we cannot make the array K-increasing in less than 4 operations. ++ +
Example 2:
+ ++Input: arr = [4,1,5,2,6,2], k = 2 +Output: 0 +Explanation: +This is the same example as the one in the problem description. +Here, for every index i where 2 <= i <= 5, arr[i-2] <= arr[i]. +Since the given array is already K-increasing, we do not need to perform any operations.+ +
Example 3:
+ ++Input: arr = [4,1,5,2,6,2], k = 3 +Output: 2 +Explanation: +Indices 3 and 5 are the only ones not satisfying arr[i-3] <= arr[i] for 3 <= i <= 5. +One of the ways we can make the array K-increasing is by changing arr[3] to 4 and arr[5] to 5. +The array will now be [4,1,5,4,6,5]. +Note that there can be other ways to make the array K-increasing, but none of them require less than 2 operations. ++ +
+
Constraints:
+ +1 <= arr.length <= 1051 <= arr[i], k <= arr.lengthGiven a string num representing the digits of a very large integer and an integer k.
You are given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integer at most k times.
You are allowed to swap any two adjacent digits of the integer at most k times.
Return the minimum integer you can obtain also as a string.
+Return the minimum integer you can obtain also as a string.
Example 1:
@@ -42,34 +40,20 @@ Explanation: We can keep the number without any swaps. -Example 4:
- --Input: num = "22", k = 22 -Output: "22" -- -
Example 5:
- --Input: num = "9438957234785635408", k = 23 -Output: "0345989723478563548" --
Constraints:
1 <= num.length <= 30000num contains digits only and doesn't have leading zeros.1 <= k <= 10^91 <= num.length <= 3 * 104num consists of only digits and does not contain leading zeros.1 <= k <= 104Example 4:
- --Input: s = "(a(b(c)d)" -Output: "a(b(c)d)" --
Constraints:
diff --git a/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md index 0e88486e6..788e77637 100644 --- a/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md +++ b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md @@ -72,6 +72,9 @@ You can skip the first and third rest to arrive in ((7/2 + 0) + (3/2 + 0) [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Minimum Speed to Arrive on Time](../minimum-speed-to-arrive-on-time) (Medium) + ### HintsYou are given a 0-indexed binary string target of length n. You have another binary string s of length n that is initially set to all zeros. You want to make s equal to target.
In one operation, you can pick an index i where 0 <= i < n and flip all bits in the inclusive range [i, n - 1]. Flip means changing '0' to '1' and '1' to '0'.
Return the minimum number of operations needed to make s equal to target.
+
Example 1:
+ ++Input: target = "10111" +Output: 3 +Explanation: Initially, s = "00000". +Choose index i = 2: "00000" -> "00111" +Choose index i = 0: "00111" -> "11000" +Choose index i = 1: "11000" -> "10111" +We need at least 3 flip operations to form target. ++ +
Example 2:
+ ++Input: target = "101" +Output: 3 +Explanation: Initially, s = "000". +Choose index i = 0: "000" -> "111" +Choose index i = 1: "111" -> "100" +Choose index i = 2: "100" -> "101" +We need at least 3 flip operations to form target. ++ +
Example 3:
+ ++Input: target = "00000" +Output: 0 +Explanation: We do not need any operations since the initial s already equals target. ++ +
+
Constraints:
+ +n == target.length1 <= n <= 105target[i] is either '0' or '1'.You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leading zeros are allowed in new1 and new2, and all the digits found in num must be used.
num = 2932, you have the following digits: two 2's, one 9 and one 3. Some of the possible pairs [new1, new2] are [22, 93], [23, 92], [223, 9] and [2, 329].Return the minimum possible sum of new1 and new2.
+
Example 1:
+ ++Input: num = 2932 +Output: 52 +Explanation: Some possible pairs [new1, new2] are [29, 23], [223, 9], etc. +The minimum sum can be obtained by the pair [29, 23]: 29 + 23 = 52. ++ +
Example 2:
+ ++Input: num = 4009 +Output: 13 +Explanation: Some possible pairs [new1, new2] are [0, 49], [490, 0], etc. +The minimum sum can be obtained by the pair [4, 9]: 4 + 9 = 13. ++ +
+
Constraints:
+ +1000 <= num <= 9999A swap is defined as taking two distinct positions in an array and swapping the values in them.
+ +A circular array is defined as an array where we consider the first element and the last element to be adjacent.
+ +Given a binary circular array nums, return the minimum number of swaps required to group all 1's present in the array together at any location.
+
Example 1:
+ ++Input: nums = [0,1,0,1,1,0,0] +Output: 1 +Explanation: Here are a few of the ways to group all the 1's together: +[0,0,1,1,1,0,0] using 1 swap. +[0,1,1,1,0,0,0] using 1 swap. +[1,1,0,0,0,0,1] using 2 swaps (using the circular property of the array). +There is no way to group all 1's together with 0 swaps. +Thus, the minimum number of swaps required is 1. ++ +
Example 2:
+ ++Input: nums = [0,1,1,1,0,0,1,1,0] +Output: 2 +Explanation: Here are a few of the ways to group all the 1's together: +[1,1,1,0,0,0,0,1,1] using 2 swaps (using the circular property of the array). +[1,1,1,1,1,0,0,0,0] using 2 swaps. +There is no way to group all 1's together with 0 or 1 swaps. +Thus, the minimum number of swaps required is 2. ++ +
Example 3:
+ ++Input: nums = [1,1,0,0,1] +Output: 0 +Explanation: All the 1's are already grouped together due to the circular property of the array. +Thus, the minimum number of swaps required is 0. ++ +
+
Constraints:
+ +1 <= nums.length <= 105nums[i] is either 0 or 1.Input: s1 = "xx", s2 = "yy" Output: 1 -Explanation: -Swap s1[0] and s2[1], s1 = "yx", s2 = "yx".+Explanation: Swap s1[0] and s2[1], s1 = "yx", s2 = "yx". +
Example 2:
Input: s1 = "xy", s2 = "yx" Output: 2 -Explanation: -Swap s1[0] and s2[0], s1 = "yy", s2 = "xx". +Explanation: Swap s1[0] and s2[0], s1 = "yy", s2 = "xx". Swap s1[0] and s2[1], s1 = "xy", s2 = "xy". -Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", cause we can only swap chars in different strings.+Note that you cannot swap s1[0] and s1[1] to make s1 equal to "yx", cause we can only swap chars in different strings. +
Example 3:
@@ -41,13 +41,6 @@ Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", Output: -1 -Example 4:
- --Input: s1 = "xxyyxyxyxx", s2 = "xyyxyxxxyx" -Output: 4 --
Constraints:
@@ -57,9 +50,12 @@ Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Determine if Two Strings Are Close](../determine-if-two-strings-are-close) (Medium) ### HintsAlice has n balloons arranged on a rope. You are given a 0-indexed string colors where colors[i] is the color of the ith balloon.
Alice wants the rope to be colorful. She does not want two consecutive balloons to be of the same color, so she asks Bob for help. Bob can remove some balloons from the rope to make it colorful. You are given a 0-indexed integer array neededTime where neededTime[i] is the time (in seconds) that Bob needs to remove the ith balloon from the rope.
Return the minimum time Bob needs to make the rope colorful.
+ ++
Example 1:
+
++Input: colors = "abaac", neededTime = [1,2,3,4,5] +Output: 3 +Explanation: In the above image, 'a' is blue, 'b' is red, and 'c' is green. +Bob can remove the blue balloon at index 2. This takes 3 seconds. +There are no longer two consecutive balloons of the same color. Total time = 3.+ +
Example 2:
+
++Input: colors = "abc", neededTime = [1,2,3] +Output: 0 +Explanation: The rope is already colorful. Bob does not need to remove any balloons from the rope. ++ +
Example 3:
+
++Input: colors = "aabaa", neededTime = [1,2,3,4,1] +Output: 2 +Explanation: Bob will remove the ballons at indices 0 and 4. Each ballon takes 1 second to remove. +There are no longer two consecutive balloons of the same color. Total time = 1 + 1 = 2. ++ +
+
Constraints:
+ +n == colors.length == neededTime.length1 <= n <= 1051 <= neededTime[i] <= 104colors contains only lowercase English letters.You are given a 0-indexed binary string s which represents a sequence of train cars. s[i] = '0' denotes that the ith car does not contain illegal goods and s[i] = '1' denotes that the ith car does contain illegal goods.
As the train conductor, you would like to get rid of all the cars containing illegal goods. You can do any of the following three operations any number of times:
+ +s[0]) which takes 1 unit of time.s[s.length - 1]) which takes 1 unit of time.Return the minimum time to remove all the cars containing illegal goods.
+ +Note that an empty sequence of cars is considered to have no cars containing illegal goods.
+ ++
Example 1:
+ ++Input: s = "1100101" +Output: 5 +Explanation: +One way to remove all the cars containing illegal goods from the sequence is to +- remove a car from the left end 2 times. Time taken is 2 * 1 = 2. +- remove a car from the right end. Time taken is 1. +- remove the car containing illegal goods found in the middle. Time taken is 2. +This obtains a total time of 2 + 1 + 2 = 5. + +An alternative way is to +- remove a car from the left end 2 times. Time taken is 2 * 1 = 2. +- remove a car from the right end 3 times. Time taken is 3 * 1 = 3. +This also obtains a total time of 2 + 3 = 5. + +5 is the minimum time taken to remove all the cars containing illegal goods. +There are no other ways to remove them with less time. ++ +
Example 2:
+ ++Input: s = "0010" +Output: 2 +Explanation: +One way to remove all the cars containing illegal goods from the sequence is to +- remove a car from the left end 3 times. Time taken is 3 * 1 = 3. +This obtains a total time of 3. + +Another way to remove all the cars containing illegal goods from the sequence is to +- remove the car containing illegal goods found in the middle. Time taken is 2. +This obtains a total time of 2. + +Another way to remove all the cars containing illegal goods from the sequence is to +- remove a car from the right end 2 times. Time taken is 2 * 1 = 2. +This obtains a total time of 2. + +2 is the minimum time taken to remove all the cars containing illegal goods. +There are no other ways to remove them with less time.+ +
+
Constraints:
+ +1 <= s.length <= 2 * 105s[i] is either '0' or '1'.Input: nums = [3,0,1] Output: 2 -Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums. +Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums.
Example 2:
@@ -27,7 +27,7 @@Input: nums = [0,1] Output: 2 -Explanation: n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range since it does not appear in nums. +Explanation: n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range since it does not appear in nums.
Example 3:
@@ -35,15 +35,7 @@Input: nums = [9,6,4,2,3,5,7,0,1] Output: 8 -Explanation: n = 9 since there are 9 numbers, so all numbers are in the range [0,9]. 8 is the missing number in the range since it does not appear in nums. -- -
Example 4:
- --Input: nums = [0] -Output: 1 -Explanation: n = 1 since there is 1 number, so all numbers are in the range [0,1]. 1 is the missing number in the range since it does not appear in nums. +Explanation: n = 9 since there are 9 numbers, so all numbers are in the range [0,9]. 8 is the missing number in the range since it does not appear in nums.
@@ -60,10 +52,10 @@
Follow up: Could you implement a solution using only O(1) extra space complexity and O(n) runtime complexity?
You have d dice and each die has f faces numbered 1, 2, ..., f. You are given three integers d, f, and target.
You have n dice and each die has k faces numbered from 1 to k.
Return the number of possible ways (out of fd total ways) modulo 109 + 7 to roll the dice so the sum of the face-up numbers equals target.
Given three integers n, k, and target, return the number of possible ways (out of the kn total ways) to roll the dice so the sum of the face-up numbers equals target. Since the answer may be too large, return it modulo 109 + 7.
Example 1:
-Input: d = 1, f = 6, target = 3 +Input: n = 1, k = 6, target = 3 Output: 1 -Explanation: -You throw one die with 6 faces. There is only one way to get a sum of 3. +Explanation: You throw one die with 6 faces. +There is only one way to get a sum of 3.
Example 2:
-Input: d = 2, f = 6, target = 7 +Input: n = 2, k = 6, target = 7 Output: 6 -Explanation: -You throw two dice, each with 6 faces. There are 6 ways to get a sum of 7: -1+6, 2+5, 3+4, 4+3, 5+2, 6+1. +Explanation: You throw two dice, each with 6 faces. +There are 6 ways to get a sum of 7: 1+6, 2+5, 3+4, 4+3, 5+2, 6+1.
Example 3:
-Input: d = 2, f = 5, target = 10 -Output: 1 -Explanation: -You throw two dice, each with 5 faces. There is only one way to get a sum of 10: 5+5. -- -
Example 4:
- --Input: d = 1, f = 2, target = 3 -Output: 0 -Explanation: -You throw one die with 2 faces. There is no way to get a sum of 3. -- -
Example 5:
- --Input: d = 30, f = 30, target = 500 +Input: n = 30, k = 30, target = 500 Output: 222616187 -Explanation: -The answer must be returned modulo 10^9 + 7. +Explanation: The answer must be returned modulo 109 + 7.
Constraints:
1 <= d, f <= 301 <= n, k <= 301 <= target <= 1000Given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.
You are given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.
Return the number of good leaf node pairs in the tree.
Example 1:
-
+
Input: root = [1,2,3,null,4], distance = 3 Output: 1 @@ -25,7 +25,7 @@
Example 2:
-
+
Input: root = [1,2,3,4,5,6,7], distance = 3 Output: 2 @@ -40,26 +40,12 @@ Explanation: The only good pair is [2,5].-
Example 4:
- --Input: root = [100], distance = 1 -Output: 0 -- -
Example 5:
- --Input: root = [1,1,1], distance = 2 -Output: 1 --
Constraints:
tree is in the range [1, 2^10].[1, 100].tree is in the range [1, 210].1 <= Node.val <= 1001 <= distance <= 10You are given a string s, a split is called good if you can split s into 2 non-empty strings p and q where its concatenation is equal to s and the number of distinct letters in p and q are the same.
You are given a string s.
Return the number of good splits you can make in s.
A split is called good if you can split s into two non-empty strings sleft and sright where their concatenation is equal to s (i.e., sleft + sright = s) and the number of distinct letters in sleft and sright is the same.
Return the number of good splits you can make in s.
Example 1:
@@ -34,29 +36,15 @@
Input: s = "abcd"
Output: 1
-Explanation: Split the string as follows ("ab", "cd").
-
-
-Example 3:
- --Input: s = "aaaaa" -Output: 4 -Explanation: All possible splits are good.- -
Example 4:
- -
-Input: s = "acbadbaada"
-Output: 2
+Explanation: Split the string as follows ("ab", "cd").
Constraints:
s contains only lowercase English letters.1 <= s.length <= 10^51 <= s.length <= 105s consists of only lowercase English letters.Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is an m x n 2D matrix. bank[i] represents the ith row, consisting of '0's and '1's. '0' means the cell is empty, while'1' means the cell has a security device.
There is one laser beam between any two security devices if both conditions are met:
+ +r1 and r2, where r1 < r2.i where r1 < i < r2, there are no security devices in the ith row.Laser beams are independent, i.e., one beam does not interfere nor join with another.
+ +Return the total number of laser beams in the bank.
+ ++
Example 1:
+
++Input: bank = ["011001","000000","010100","001000"] +Output: 8 +Explanation: Between each of the following device pairs, there is one beam. In total, there are 8 beams: + * bank[0][1] -- bank[2][1] + * bank[0][1] -- bank[2][3] + * bank[0][2] -- bank[2][1] + * bank[0][2] -- bank[2][3] + * bank[0][5] -- bank[2][1] + * bank[0][5] -- bank[2][3] + * bank[2][1] -- bank[3][2] + * bank[2][3] -- bank[3][2] +Note that there is no beam between any device on the 0th row with any on the 3rd row. +This is because the 2nd row contains security devices, which breaks the second condition. ++ +
Example 2:
+
++Input: bank = ["000","111","000"] +Output: 0 +Explanation: There does not exist two devices located on two different rows. ++ +
+
Constraints:
+ +m == bank.lengthn == bank[i].length1 <= m, n <= 500bank[i][j] is either '0' or '1'.Given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has the label labels[i]).
You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has the label labels[i]).
The edges array is given on the form edges[i] = [ai, bi], which means there is an edge between nodes ai and bi in the tree.
Return an array of size n where ans[i] is the number of nodes in the subtree of the ith node which have the same label as node i.
Return an array of size n where ans[i] is the number of nodes in the subtree of the ith node which have the same label as node i.
A subtree of a tree T is the tree consisting of a node in T and all of its descendant nodes.
A subtree of a tree T is the tree consisting of a node in T and all of its descendant nodes.
Example 1:
-
+
Input: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], labels = "abaedcd" Output: [2,1,1,1,1,1,1] @@ -30,7 +30,7 @@ Node 1 has a label 'b'. The sub-tree of node 1 contains nodes 1,4 and 5,
Example 2:
-
+
Input: n = 4, edges = [[0,1],[1,2],[0,3]], labels = "bbbb" Output: [4,2,1,1] @@ -41,37 +41,23 @@ The sub-tree of node 0 contains nodes 0, 1, 2 and 3, all with label 'b',
Example 3:
-
+
Input: n = 5, edges = [[0,1],[0,2],[1,3],[0,4]], labels = "aabab" Output: [3,2,1,1,1]-
Example 4:
- --Input: n = 6, edges = [[0,1],[0,2],[1,3],[3,4],[4,5]], labels = "cbabaa" -Output: [1,2,1,1,2,1] -- -
Example 5:
- --Input: n = 7, edges = [[0,1],[1,2],[2,3],[3,4],[4,5],[5,6]], labels = "aaabaaa" -Output: [6,5,4,1,3,2,1] --
Constraints:
1 <= n <= 10^51 <= n <= 105edges.length == n - 1edges[i].length == 20 <= ai, bi < nai != bi0 <= ai, bi < nai != bilabels.length == nlabels is consisting of only of lower-case English letters.labels is consisting of only of lowercase English letters.There are n computers numbered from 0 to n-1 connected by ethernet cables connections forming a network where connections[i] = [a, b] represents a connection between computers a and b. Any computer can reach any other computer directly or indirectly through the network.
There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a connection between computers ai and bi. Any computer can reach any other computer directly or indirectly through the network.
Given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected. Return the minimum number of times you need to do this in order to make all the computers connected. If it's not possible, return -1.
You are given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected.
Return the minimum number of times you need to do this in order to make all the computers connected. If it is not possible, return -1.
Example 1:
- -
Input: n = 4, connections = [[0,1],[0,2],[1,2]] Output: 1 @@ -27,9 +27,7 @@
Example 2:
- -
Input: n = 6, connections = [[0,1],[0,2],[0,3],[1,2],[1,3]] Output: 2 @@ -43,22 +41,15 @@ Explanation: There are not enough cables.-
Example 4:
- --Input: n = 5, connections = [[0,1],[0,2],[3,4],[2,3]] -Output: 0 --
Constraints:
1 <= n <= 10^51 <= connections.length <= min(n*(n-1)/2, 10^5)1 <= n <= 1051 <= connections.length <= min(n * (n - 1) / 2, 105)connections[i].length == 20 <= connections[i][0], connections[i][1] < nconnections[i][0] != connections[i][1]0 <= ai, bi < nai != biYou are given a string s, return the number of segments in the string.
Given a string s, return the number of segments in the string.
A segment is defined to be a contiguous sequence of non-space characters.
@@ -31,26 +31,12 @@ Output: 1 -Example 3:
- --Input: s = "love live! mu'sic forever" -Output: 4 -- -
Example 4:
- --Input: s = "" -Output: 0 --
Constraints:
0 <= s.length <= 300s consists of lower-case and upper-case English letters, digits or one of the following characters "!@#$%^&*()_+-=',.:".s consists of lowercase and uppercase English letters, digits, or one of the following characters "!@#$%^&*()_+-=',.:".s is ' '.Given n points on a 1-D plane, where the ith point (from 0 to n-1) is at x = i, find the number of ways we can draw exactly k non-overlapping line segments such that each segment covers two or more points. The endpoints of each segment must have integral coordinates. The k line segments do not have to cover all n points, and they are allowed to share endpoints.
Return the number of ways we can draw k non-overlapping line segments. Since this number can be huge, return it modulo 109 + 7.
Return the number of ways we can draw k non-overlapping line segments. Since this number can be huge, return it modulo 109 + 7.
Example 1:
@@ -21,16 +21,16 @@
Input: n = 4, k = 2
Output: 5
-Explanation:
-The two line segments are shown in red and blue.
-The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),(2,3)}, {(1,2),(2,3)}, {(0,1),(1,2)}.
+Explanation: The two line segments are shown in red and blue.
+The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),(2,3)}, {(1,2),(2,3)}, {(0,1),(1,2)}.
+
Example 2:
Input: n = 3, k = 1
Output: 3
-Explanation: The 3 ways are {(0,1)}, {(0,2)}, {(1,2)}.
+Explanation: The 3 ways are {(0,1)}, {(0,2)}, {(1,2)}.
Example 3:
@@ -38,22 +38,9 @@ The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),Input: n = 30, k = 7 Output: 796297179 -Explanation: The total number of possible ways to draw 7 line segments is 3796297200. Taking this number modulo 109 + 7 gives us 796297179. -- -
Example 4:
- --Input: n = 5, k = 3 -Output: 7 +Explanation: The total number of possible ways to draw 7 line segments is 3796297200. Taking this number modulo 109 + 7 gives us 796297179.-
Example 5:
- --Input: n = 3, k = 2 -Output: 1-
Constraints:
diff --git a/problems/number-of-smooth-descent-periods-of-a-stock/README.md b/problems/number-of-smooth-descent-periods-of-a-stock/README.md new file mode 100644 index 000000000..8a05be526 --- /dev/null +++ b/problems/number-of-smooth-descent-periods-of-a-stock/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../adding-spaces-to-a-string "Adding Spaces to a String") + +[Next >](../minimum-operations-to-make-the-array-k-increasing "Minimum Operations to Make the Array K-Increasing") + +## [2110. Number of Smooth Descent Periods of a Stock (Medium)](https://leetcode.com/problems/number-of-smooth-descent-periods-of-a-stock "股票平滑下跌阶段的数目") + +You are given an integer array prices representing the daily price history of a stock, where prices[i] is the stock price on the ith day.
A smooth descent period of a stock consists of one or more contiguous days such that the price on each day is lower than the price on the preceding day by exactly 1. The first day of the period is exempted from this rule.
Return the number of smooth descent periods.
+ ++
Example 1:
+ ++Input: prices = [3,2,1,4] +Output: 7 +Explanation: There are 7 smooth descent periods: +[3], [2], [1], [4], [3,2], [2,1], and [3,2,1] +Note that a period with one day is a smooth descent period by the definition. ++ +
Example 2:
+ ++Input: prices = [8,6,7,7] +Output: 4 +Explanation: There are 4 smooth descent periods: [8], [6], [7], and [7] +Note that [8,6] is not a smooth descent period as 8 - 6 ≠ 1. ++ +
Example 3:
+ ++Input: prices = [1] +Output: 1 +Explanation: There is 1 smooth descent period: [1] ++ +
+
Constraints:
+ +1 <= prices.length <= 1051 <= prices[i] <= 105The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].
Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.
Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.
Example 1:
@@ -37,27 +37,6 @@ The third student started doing homework at time 3 and finished at time 7 and wa Explanation: The only student was doing their homework at the queryTime. -Example 3:
- --Input: startTime = [4], endTime = [4], queryTime = 5 -Output: 0 -- -
Example 4:
- --Input: startTime = [1,1,1,1], endTime = [1,3,2,4], queryTime = 7 -Output: 0 -- -
Example 5:
- --Input: startTime = [9,8,7,6,5,4,3,2,1], endTime = [10,10,10,10,10,10,10,10,10], queryTime = 5 -Output: 5 --
Constraints:
@@ -65,7 +44,7 @@ The third student started doing homework at time 3 and finished at time 7 and wastartTime.length == endTime.length1 <= startTime.length <= 1001 <= startTime[i] <= endTime[i] <= 10001 <= queryTime <= 10001 <= queryTime <= 1000Given an array of integers arr and two integers k and threshold.
Return the number of sub-arrays of size k and average greater than or equal to threshold.
Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.
Example 1:
@@ -26,41 +24,20 @@Example 2:
--Input: arr = [1,1,1,1,1], k = 1, threshold = 0 -Output: 5 -- -
Example 3:
-Input: arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5 Output: 6 Explanation: The first 6 sub-arrays of size 3 have averages greater than 5. Note that averages are not integers.-
Example 4:
- --Input: arr = [7,7,7,7,7,7,7], k = 7, threshold = 7 -Output: 1 -- -
Example 5:
- --Input: arr = [4,4,4,4], k = 4, threshold = 1 -Output: 1 --
Constraints:
1 <= arr.length <= 10^51 <= arr[i] <= 10^41 <= arr.length <= 1051 <= arr[i] <= 1041 <= k <= arr.length0 <= threshold <= 10^40 <= threshold <= 104Given an array of integers nums and an integer target.
You are given an array of integers nums and an integer target.
Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.
Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.
Example 1:
@@ -21,7 +21,7 @@Input: nums = [3,5,6,7], target = 9 Output: 4 -Explanation: There are 4 subsequences that satisfy the condition. +Explanation: There are 4 subsequences that satisfy the condition. [3] -> Min value + max value <= target (3 + 3 <= 9) [3,5] -> (3 + 5 <= 9) [3,5,6] -> (3 + 6 <= 9) @@ -33,25 +33,19 @@Input: nums = [3,3,6,8], target = 10 Output: 6 -Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers). -[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]+Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers). +[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6] +
Example 3:
Input: nums = [2,3,3,4,6,7], target = 12 Output: 61 -Explanation: There are 63 non-empty subsequences, two of them don't satisfy the condition ([6,7], [7]). +Explanation: There are 63 non-empty subsequences, two of them do not satisfy the condition ([6,7], [7]). Number of valid subsequences (63 - 2 = 61).-
Example 4:
- --Input: nums = [5,2,4,1,7,6,8], target = 16 -Output: 127 -Explanation: All non-empty subset satisfy the condition (2^7 - 1) = 127-
Constraints:
diff --git a/problems/number-of-substrings-with-only-1s/README.md b/problems/number-of-substrings-with-only-1s/README.md index ac9643cdb..3e0062cdb 100644 --- a/problems/number-of-substrings-with-only-1s/README.md +++ b/problems/number-of-substrings-with-only-1s/README.md @@ -40,13 +40,6 @@ Explanation: Each substring contains only 1's characters. -Example 4:
- --Input: s = "000" -Output: 0 --
Constraints:
@@ -59,6 +52,10 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Count Number of Homogenous Substrings](../count-number-of-homogenous-substrings) (Medium) + 1. [Count Vowel Substrings of a String](../count-vowel-substrings-of-a-string) (Easy) + ### HintsExample 4:
-
--Input: pieces = ["rook","rook"], positions = [[1,1],[8,8]] -Output: 223 -Explanation: There are 15 moves for each rook which results in 15 * 15 = 225 move combinations. -However, there are two invalid move combinations: -- Move both rooks to (8, 1), where they collide. -- Move both rooks to (1, 8), where they collide. -Thus there are 225 - 2 = 223 valid move combinations. -Note that there are two valid move combinations that would result in one rook at (1, 8) and the other at (8, 1). -Even though the board state is the same, these two move combinations are considered different since the moves themselves are different. -- -
Example 5:
-
--Input: pieces = ["queen","bishop"], positions = [[5,7],[3,4]] -Output: 281 -Explanation: There are 12 * 24 = 288 move combinations. -However, there are several invalid move combinations: -- If the queen stops at (6, 7), it blocks the bishop from moving to (6, 7) or (7, 8). -- If the queen stops at (5, 6), it blocks the bishop from moving to (5, 6), (6, 7), or (7, 8). -- If the bishop stops at (5, 2), it blocks the queen from moving to (5, 2) or (5, 1). -Of the 288 move combinations, 281 are valid. --
Constraints:
@@ -92,10 +65,10 @@ Of the 288 move combinations, 281 are valid.n == pieces.length n == positions.length1 <= n <= 4pieces only contains the strings "rook", "queen", and "bishop".pieces only contains the strings "rook", "queen", and "bishop".1 <= xi, yi <= 8positions[i] is distinct.positions[i] is distinct.Example 4:
- --Input: sentence = "he bought 2 pencils, 3 erasers, and 1 pencil-sharpener." -Output: 6 -Explanation: The valid words in the sentence are "he", "bought", "pencils,", "erasers,", "and", and "pencil-sharpener.". --
Constraints:
diff --git a/problems/number-of-ways-to-divide-a-long-corridor/README.md b/problems/number-of-ways-to-divide-a-long-corridor/README.md new file mode 100644 index 000000000..020172312 --- /dev/null +++ b/problems/number-of-ways-to-divide-a-long-corridor/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../k-highest-ranked-items-within-a-price-range "K Highest Ranked Items Within a Price Range") + +[Next >](../count-elements-with-strictly-smaller-and-greater-elements "Count Elements With Strictly Smaller and Greater Elements ") + +## [2147. Number of Ways to Divide a Long Corridor (Hard)](https://leetcode.com/problems/number-of-ways-to-divide-a-long-corridor "分隔长廊的方案数") + +Along a long library corridor, there is a line of seats and decorative plants. You are given a 0-indexed string corridor of length n consisting of letters 'S' and 'P' where each 'S' represents a seat and each 'P' represents a plant.
One room divider has already been installed to the left of index 0, and another to the right of index n - 1. Additional room dividers can be installed. For each position between indices i - 1 and i (1 <= i <= n - 1), at most one divider can be installed.
Divide the corridor into non-overlapping sections, where each section has exactly two seats with any number of plants. There may be multiple ways to perform the division. Two ways are different if there is a position with a room divider installed in the first way but not in the second way.
+ +Return the number of ways to divide the corridor. Since the answer may be very large, return it modulo 109 + 7. If there is no way, return 0.
+
Example 1:
+
++Input: corridor = "SSPPSPS" +Output: 3 +Explanation: There are 3 different ways to divide the corridor. +The black bars in the above image indicate the two room dividers already installed. +Note that in each of the ways, each section has exactly two seats. ++ +
Example 2:
+
++Input: corridor = "PPSPSP" +Output: 1 +Explanation: There is only 1 way to divide the corridor, by not installing any additional dividers. +Installing any would create some section that does not have exactly two seats. ++ +
Example 3:
+
++Input: corridor = "S" +Output: 0 +Explanation: There is no way to divide the corridor because there will always be a section that does not have exactly two seats. ++ +
+
Constraints:
+ +n == corridor.length1 <= n <= 105corridor[i] is either 'S' or 'P'.target.Notice that you can use multiple characters from the same string in words provided the conditions above are met.
Notice that you can use multiple characters from the same string in words provided the conditions above are met.
Return the number of ways to form target from words. Since the answer may be too large, return it modulo 109 + 7.
Example 3:
- --Input: words = ["abcd"], target = "abcd" -Output: 1 -- -
Example 4:
- --Input: words = ["abab","baba","abba","baab"], target = "abba" -Output: 16 --
Constraints:
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 5b1198fdb..aea32d531 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 @@ -26,27 +26,6 @@Example 2:
--Input: n = 2 -Output: 54 -- -
Example 3:
- --Input: n = 3 -Output: 246 -- -
Example 4:
- --Input: n = 7 -Output: 106494 -- -
Example 5:
-Input: n = 5000 Output: 30228214 @@ -57,13 +36,15 @@
n == grid.lengthgrid[i].length == 31 <= n <= 5000Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nums in order into an initially empty BST. Find the number of different ways to reorder nums so that the constructed BST is identical to that formed from the original array nums.
Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nums in order into an initially empty BST. Find the number of different ways to reorder nums so that the constructed BST is identical to that formed from the original array nums.
For example, given nums = [2,1,3], we will have 2 as the root, 1 as a left child, and 3 as a right child. The array [2,3,1] also yields the same BST but [3,2,1] yields a different BST.
nums = [2,1,3], we will have 2 as the root, 1 as a left child, and 3 as a right child. The array [2,3,1] also yields the same BST but [3,2,1] yields a different BST.Return the number of ways to reorder nums such that the BST formed is identical to the original BST formed from nums.
Return the number of ways to reorder nums such that the BST formed is identical to the original BST formed from nums.
Since the answer may be very large, return it modulo 10^9 + 7.
Since the answer may be very large, return it modulo 109 + 7.
Example 1:
- -
Input: nums = [2,1,3] Output: 1 -Explanation: We can reorder nums to be [2,3,1] which will yield the same BST. There are no other ways to reorder nums which will yield the same BST. +Explanation: We can reorder nums to be [2,3,1] which will yield the same BST. There are no other ways to reorder nums which will yield the same BST.
Example 2:
- -
Input: nums = [3,4,5,1,2] Output: 5 -Explanation: The following 5 arrays will yield the same BST: +Explanation: The following 5 arrays will yield the same BST: [3,1,2,4,5] [3,1,4,2,5] [3,1,4,5,2] @@ -46,30 +44,11 @@
Example 3:
- -
Input: nums = [1,2,3] Output: 0 -Explanation: There are no other orderings of nums that will yield the same BST. -- -
Example 4:
- -
-Input: nums = [3,1,2,5,4,6] -Output: 19 -- -
Example 5:
- --Input: nums = [9,4,2,1,3,6,5,7,8,14,11,10,12,13,16,15,17,18] -Output: 216212978 -Explanation: The number of ways to reorder nums to get the same BST is 3216212999. Taking this number modulo 10^9 + 7 gives 216212978. +Explanation: There are no other orderings of nums that will yield the same BST.
@@ -78,20 +57,20 @@
1 <= nums.length <= 10001 <= nums[i] <= nums.lengthnums are distinct.nums are distinct.Input: num = "327" Output: 2 -Explanation: You could have written down the numbers: +Explanation: You could have written down the numbers: 3, 27 327@@ -31,7 +31,7 @@
Input: num = "094" Output: 0 -Explanation: No numbers can have leading zeros and all numbers must be positive. +Explanation: No numbers can have leading zeros and all numbers must be positive.
Example 3:
@@ -39,14 +39,7 @@Input: num = "0" Output: 0 -Explanation: No numbers can have leading zeros and all numbers must be positive. -- -
Example 4:
- --Input: num = "9999999999999" -Output: 101 +Explanation: No numbers can have leading zeros and all numbers must be positive.
diff --git a/problems/number-of-ways-to-split-a-string/README.md b/problems/number-of-ways-to-split-a-string/README.md index cfdbf11da..9874c1112 100644 --- a/problems/number-of-ways-to-split-a-string/README.md +++ b/problems/number-of-ways-to-split-a-string/README.md @@ -11,11 +11,9 @@ ## [1573. Number of Ways to Split a String (Medium)](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") -
Given a binary string s (a string consisting only of '0's and '1's), we can split s into 3 non-empty strings s1, s2, s3 (s1+ s2+ s3 = s).
Given a binary string s, you can split s into 3 non-empty strings s1, s2, and s3 where s1 + s2 + s3 = s.
Return the number of ways s can be split such that the number of characters '1' is the same in s1, s2, and s3.
Since the answer may be too large, return it modulo 10^9 + 7.
+Return the number of ways s can be split such that the number of ones is the same in s1, s2, and s3. Since the answer may be too large, return it modulo 109 + 7.
Example 1:
@@ -48,25 +46,21 @@ "00|0|0" -Example 4:
- --Input: s = "100100010100110" -Output: 12 --
Constraints:
3 <= s.length <= 10^5s[i] is '0' or '1'.3 <= s.length <= 105s[i] is either '0' or '1'.There are n people and 40 types of hats labeled from 1 to 40.
There are n people and 40 types of hats labeled from 1 to 40.
Given a list of list of integers hats, where hats[i] is a list of all hats preferred by the i-th person.
Given a 2D integer array hats, where hats[i] is a list of all hats preferred by the ith person.
Return the number of ways that the n people wear different hats to each other.
+Return the number of ways that the n people wear different hats to each other.
Since the answer may be too large, return it modulo 10^9 + 7.
Since the answer may be too large, return it modulo 109 + 7.
Example 1:
@@ -25,15 +25,16 @@Input: hats = [[3,4],[4,5],[5]] Output: 1 -Explanation: There is only one way to choose hats given the conditions. -First person choose hat 3, Second person choose hat 4 and last one hat 5.+Explanation: There is only one way to choose hats given the conditions. +First person choose hat 3, Second person choose hat 4 and last one hat 5. +
Example 2:
Input: hats = [[3,5,1],[3,5]] Output: 4 -Explanation: There are 4 ways to choose hats +Explanation: There are 4 ways to choose hats: (3,5), (5,3), (1,3) and (1,5)@@ -42,17 +43,10 @@ First person choose hat 3, Second person choose hat 4 and last one hat 5.
Input: hats = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]] Output: 24 -Explanation: Each person can choose hats labeled from 1 to 4. +Explanation: Each person can choose hats labeled from 1 to 4. Number of Permutations of (1,2,3,4) = 24.-
Example 4:
- --Input: hats = [[1,2,3],[2,3,5,6],[1,3,7,9],[1,8,9],[2,5,7]] -Output: 111 --
Constraints:
diff --git a/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md index 4a9a83b5e..9a7b126db 100644 --- a/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md +++ b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md @@ -7,15 +7,15 @@ [< Previous](../replace-all-s-to-avoid-consecutive-repeating-characters "Replace All ?'s to Avoid Consecutive Repeating Characters") -[Next >](../minimum-deletion-cost-to-avoid-repeating-letters "Minimum Deletion Cost to Avoid Repeating Letters") +[Next >](../minimum-time-to-make-rope-colorful "Minimum Time to Make Rope Colorful") ## [1577. Number of Ways Where Square of Number Is Equal to Product of Two Numbers (Medium)](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") -Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.nums2[i]2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.nums2[i]2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.@@ -24,7 +24,7 @@
Input: nums1 = [7,4], nums2 = [5,2,8,9] Output: 1 -Explanation: Type 1: (1,1,2), nums1[1]^2 = nums2[1] * nums2[2]. (4^2 = 2 * 8). +Explanation: Type 1: (1, 1, 2), nums1[1]2 = nums2[1] * nums2[2]. (42 = 2 * 8).
Example 2:
@@ -32,9 +32,9 @@Input: nums1 = [1,1], nums2 = [1,1,1] Output: 9 -Explanation: All Triplets are valid, because 1^2 = 1 * 1. -Type 1: (0,0,1), (0,0,2), (0,1,2), (1,0,1), (1,0,2), (1,1,2). nums1[i]^2 = nums2[j] * nums2[k]. -Type 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]^2 = nums1[j] * nums1[k]. +Explanation: All Triplets are valid, because 12 = 1 * 1. +Type 1: (0,0,1), (0,0,2), (0,1,2), (1,0,1), (1,0,2), (1,1,2). nums1[i]2 = nums2[j] * nums2[k]. +Type 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]2 = nums1[j] * nums1[k].
Example 3:
@@ -43,16 +43,8 @@ Type 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]^2 = nums1[j] * nums1[k]. Input: nums1 = [7,7,8,3], nums2 = [1,2,9,7] Output: 2 Explanation: There are 2 valid triplets. -Type 1: (3,0,2). nums1[3]^2 = nums2[0] * nums2[2]. -Type 2: (3,0,1). nums2[3]^2 = nums1[0] * nums1[1]. - - -Example 4:
- --Input: nums1 = [4,7,9,11,23], nums2 = [3,5,1024,12,18] -Output: 0 -Explanation: There are no valid triplets. +Type 1: (3,0,2). nums1[3]2 = nums2[0] * nums2[2]. +Type 2: (3,0,1). nums2[3]2 = nums1[0] * nums1[1].
@@ -60,7 +52,7 @@ Type 2: (3,0,1). nums2[3]^2 = nums1[0] * nums1[1].
1 <= nums1.length, nums2.length <= 10001 <= nums1[i], nums2[i] <= 10^51 <= nums1[i], nums2[i] <= 105houses = [1,2,2,3,3,2,1,1] contains 5 neighborhoods [{1}, {2,2}, {3,3}, {2}, {1,1}].Given an array houses, an m x n matrix cost and an integer target where:
Given an array houses, an m x n matrix cost and an integer target where:
houses[i]: is the color of the house i, and 0 if the house is not painted yet.Example 3:
--Input: houses = [0,0,0,0,0], cost = [[1,10],[10,1],[1,10],[10,1],[1,10]], m = 5, n = 2, target = 5 -Output: 5 -- -
Example 4:
-Input: houses = [3,1,2,3], cost = [[1,1,1],[1,1,1],[1,1,1],[1,1,1]], m = 4, n = 3, target = 3 Output: -1 @@ -74,7 +67,7 @@ Cost of paint the first and last house (10 + 1) = 11.
1 <= n <= 201 <= target <= m0 <= houses[i] <= n1 <= cost[i][j] <= 10^41 <= cost[i][j] <= 104You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied:
pivot appears before every element greater than pivot.pivot appears in between the elements less than and greater than pivot.pivot and the elements greater than pivot is maintained.
+ pi, pj where pi is the new position of the ith element and pj is the new position of the jth element. For elements less than pivot, if i < j and nums[i] < pivot and nums[j] < pivot, then pi < pj. Similarly for elements greater than pivot, if i < j and nums[i] > pivot and nums[j] > pivot, then pi < pj.Return nums after the rearrangement.
+
Example 1:
+ ++Input: nums = [9,12,5,10,14,3,10], pivot = 10 +Output: [9,5,3,10,10,12,14] +Explanation: +The elements 9, 5, and 3 are less than the pivot so they are on the left side of the array. +The elements 12 and 14 are greater than the pivot so they are on the right side of the array. +The relative ordering of the elements less than and greater than pivot is also maintained. [9, 5, 3] and [12, 14] are the respective orderings. ++ +
Example 2:
+ ++Input: nums = [-3,4,3,2], pivot = 2 +Output: [-3,2,4,3] +Explanation: +The element -3 is less than the pivot so it is on the left side of the array. +The elements 4 and 3 are greater than the pivot so they are on the right side of the array. +The relative ordering of the elements less than and greater than pivot is also maintained. [-3] and [4, 3] are the respective orderings. ++ +
+
Constraints:
+ +1 <= nums.length <= 105-106 <= nums[i] <= 106pivot equals to an element of nums.Input: root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22 Output: true +Explanation: The root-to-leaf path with the target sum is shown.
Example 2:
@@ -28,13 +29,18 @@Input: root = [1,2,3], targetSum = 5 Output: false +Explanation: There two root-to-leaf paths in the tree: +(1 --> 2): The sum is 3. +(1 --> 3): The sum is 4. +There is no root-to-leaf path with sum = 5.
Example 3:
-Input: root = [1,2], targetSum = 0 +Input: root = [], targetSum = 0 Output: false +Explanation: Since the tree is empty, there are no root-to-leaf paths.
@@ -49,6 +55,7 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/path-with-minimum-effort/README.md b/problems/path-with-minimum-effort/README.md index b964c1049..9cee131df 100644 --- a/problems/path-with-minimum-effort/README.md +++ b/problems/path-with-minimum-effort/README.md @@ -58,17 +58,13 @@ This is better than the route of [1,2,2,2,5], where the maximum absolute differe ### Related Topics - [[Array](../../tag/array/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Matrix](../../tag/matrix/README.md)] - -### Similar Questions - 1. [Swim in Rising Water](../swim-in-rising-water) (Hard) - 1. [Path With Maximum Minimum Value](../path-with-maximum-minimum-value) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
Example 3:
-
--Input: rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[3,2,4,4]] -Output: false -Explanation: Because there is a gap in the top center. -- -
Example 4:
Input: rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[2,2,4,4]] diff --git a/problems/pizza-with-3n-slices/README.md b/problems/pizza-with-3n-slices/README.md index fb5a05914..eb813cd89 100644 --- a/problems/pizza-with-3n-slices/README.md +++ b/problems/pizza-with-3n-slices/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-integers-by-the-power-value "Sort Integers by The Power Value") @@ -11,24 +11,20 @@ ## [1388. Pizza With 3n Slices (Hard)](https://leetcode.com/problems/pizza-with-3n-slices "3n 块披萨") -There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:
+There is a pizza with
3nslices of varying size, you and your friends will take slices of pizza as follows:
Sizes of Pizza slices is represented by circular array slices in clockwise direction.
Return the maximum possible sum of slice sizes which you can have.
+Given an integer array slices that represent the sizes of the pizza slices in a clockwise direction, return the maximum possible sum of slice sizes that you can pick.
Example 1:
- -
Input: slices = [1,2,3,4,5,6] Output: 10 @@ -36,35 +32,19 @@
Example 2:
- -
Input: slices = [8,9,8,6,1,1] Output: 16 -Output: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8. -- -
Example 3:
- --Input: slices = [4,1,2,5,8,3,1,9,7] -Output: 21 -- -
Example 4:
- --Input: slices = [3,1,2] -Output: 3 +Explanation: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.
Constraints:
3 * n == slices.length1 <= slices.length <= 500slices.length % 3 == 01 <= slices[i] <= 1000Given an integer n, return true if it is a power of three. Otherwise, return false.
Example 1:
-Input: n = 27 + +-+Input: n = 27 Output: true -Example 2:
-Input: n = 0 ++ +Example 2:
+ ++Input: n = 0 Output: false -Example 3:
-Input: n = 9 ++ +Example 3:
+ ++Input: n = 9 Output: true -Example 4:
-Input: n = 45 -Output: false+
Constraints:
diff --git a/problems/prime-arrangements/README.md b/problems/prime-arrangements/README.md index b85fa61f2..bb7caddf2 100644 --- a/problems/prime-arrangements/README.md +++ b/problems/prime-arrangements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../immediate-food-delivery-ii "Immediate Food Delivery II") diff --git a/problems/print-in-order/README.md b/problems/print-in-order/README.md index b97cb6ac8..2f0675943 100644 --- a/problems/print-in-order/README.md +++ b/problems/print-in-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reported-posts "Reported Posts") diff --git a/problems/prison-cells-after-n-days/README.md b/problems/prison-cells-after-n-days/README.md index fe203b401..1459ec6aa 100644 --- a/problems/prison-cells-after-n-days/README.md +++ b/problems/prison-cells-after-n-days/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tallest-billboard "Tallest Billboard") @@ -60,7 +60,7 @@ Day 7: [0, 0, 1, 1, 0, 0, 0, 0] ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md index 40e16a1df..4e558e1e6 100644 --- a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md +++ b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md @@ -53,22 +53,6 @@ Probability is 8/12 = 0.66667 Probability = 108 / 180 = 0.6
Example 4:
- --Input: balls = [3,2,1] -Output: 0.30000 -Explanation: The set of balls is [1, 1, 1, 2, 2, 3]. It is hard to display all the 60 possible random shuffles of this set but it is easy to check that 18 of them will have the same number of distinct colors in each box. -Probability = 18 / 60 = 0.3 -- -
Example 5:
- --Input: balls = [6,6,6,6,6,6] -Output: 0.90327 --
Constraints:
diff --git a/problems/product-of-array-except-self/README.md b/problems/product-of-array-except-self/README.md index 665cd7199..0b3fe0d47 100644 --- a/problems/product-of-array-except-self/README.md +++ b/problems/product-of-array-except-self/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-node-in-a-linked-list "Delete Node in a Linked List") diff --git a/problems/products-price-for-each-store/README.md b/problems/products-price-for-each-store/README.md index 5d46b038f..ad3e0f768 100644 --- a/problems/products-price-for-each-store/README.md +++ b/problems/products-price-for-each-store/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Rearrange Products Table](../rearrange-products-table) (Easy) diff --git a/problems/projection-area-of-3d-shapes/README.md b/problems/projection-area-of-3d-shapes/README.md index 5d23f8dbe..645e1c1af 100644 --- a/problems/projection-area-of-3d-shapes/README.md +++ b/problems/projection-area-of-3d-shapes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reachable-nodes-in-subdivided-graph "Reachable Nodes In Subdivided Graph") @@ -44,27 +44,12 @@ Output: 8 -Example 4:
- --Input: grid = [[1,1,1],[1,0,1],[1,1,1]] -Output: 14 -- -
Example 5:
- --Input: grid = [[2,2,2],[2,1,2],[2,2,2]] -Output: 21 --
Constraints:
n == grid.lengthn == grid[i].length1 <= n <= 50n == grid.length == grid[i].length1 <= n <= 500 <= grid[i][j] <= 50You are given an array of positive integers w where w[i] describes the weight of ith index (0-indexed).
You are given a 0-indexed array of positive integers w where w[i] describes the weight of the ith index.
We need to call the function pickIndex() which randomly returns an integer in the range [0, w.length - 1]. pickIndex() should return the integer proportional to its weight in the w array. For example, for w = [1, 3], the probability of picking the index 0 is 1 / (1 + 3) = 0.25 (i.e 25%) while the probability of picking the index 1 is 3 / (1 + 3) = 0.75 (i.e 75%).
You need to implement the function pickIndex(), which randomly picks an index in the range [0, w.length - 1] (inclusive) and returns it. The probability of picking an index i is w[i] / sum(w).
More formally, the probability of picking index i is w[i] / sum(w).
w = [1, 3], the probability of picking index 0 is 1 / (1 + 3) = 0.25 (i.e., 25%), and the probability of picking index 1 is 3 / (1 + 3) = 0.75 (i.e., 75%).
Example 1:
@@ -29,7 +31,7 @@ Explanation Solution solution = new Solution([1]); -solution.pickIndex(); // return 0. Since there is only one single element on the array the only option is to return the first element. +solution.pickIndex(); // return 0. The only option is to return 0 since there is only one element in w.Example 2:
@@ -43,13 +45,14 @@ solution.pickIndex(); // return 0. Since there is only one single element on the Explanation Solution solution = new Solution([1, 3]); -solution.pickIndex(); // return 1. It's returning the second element (index = 1) that has probability of 3/4. +solution.pickIndex(); // return 1. It is returning the second element (index = 1) that has a probability of 3/4. solution.pickIndex(); // return 1 solution.pickIndex(); // return 1 solution.pickIndex(); // return 1 -solution.pickIndex(); // return 0. It's returning the first element (index = 0) that has probability of 1/4. +solution.pickIndex(); // return 0. It is returning the first element (index = 0) that has a probability of 1/4. -Since this is a randomization problem, multiple answers are allowed so the following outputs can be considered correct : +Since this is a randomization problem, multiple answers are allowed. +All of the following outputs can be considered correct: [null,1,1,1,1,0] [null,1,1,1,1,1] [null,1,1,1,0,0] @@ -63,9 +66,9 @@ and so on.Constraints:
1 <= w.length <= 100001 <= w[i] <= 10^5pickIndex will be called at most 10000 times.1 <= w.length <= 1041 <= w[i] <= 105pickIndex will be called at most 104 times.It is guaranteed that answer is unique under the given rules.
The test cases are generated so that answer is unique under the given rules.
Example 1:
@@ -56,13 +56,6 @@ The rank of matrix[1][1] is 3 because matrix[1][1] > matrix[0][1], matrix[1][ Output: [[4,2,3],[1,3,4],[5,1,6],[1,3,4]] -Example 4:
-
--Input: matrix = [[7,3,6],[1,4,5],[9,8,2]] -Output: [[5,1,4],[1,2,3],[6,3,1]] --
Constraints:
diff --git a/problems/reach-a-number/README.md b/problems/reach-a-number/README.md index c9cfef930..3d3d442ee 100644 --- a/problems/reach-a-number/README.md +++ b/problems/reach-a-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cracking-the-safe "Cracking the Safe") diff --git a/problems/rearrange-array-elements-by-sign/README.md b/problems/rearrange-array-elements-by-sign/README.md new file mode 100644 index 000000000..42e6a72bd --- /dev/null +++ b/problems/rearrange-array-elements-by-sign/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../count-elements-with-strictly-smaller-and-greater-elements "Count Elements With Strictly Smaller and Greater Elements ") + +[Next >](../find-all-lonely-numbers-in-the-array "Find All Lonely Numbers in the Array") + +## [2149. Rearrange Array Elements by Sign (Medium)](https://leetcode.com/problems/rearrange-array-elements-by-sign "按符号重排数组") + +You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.
You should rearrange the elements of nums such that the modified array follows the given conditions:
nums is preserved.Return the modified array after rearranging the elements to satisfy the aforementioned conditions.
+ ++
Example 1:
+ ++Input: nums = [3,1,-2,-5,2,-4] +Output: [3,-2,1,-5,2,-4] +Explanation: +The positive integers in nums are [3,1,2]. The negative integers are [-2,-5,-4]. +The only possible way to rearrange them such that they satisfy all conditions is [3,-2,1,-5,2,-4]. +Other ways such as [1,-2,2,-5,3,-4], [3,1,2,-2,-5,-4], [-2,3,-5,1,-4,2] are incorrect because they do not satisfy one or more conditions. ++ +
Example 2:
+ ++Input: nums = [-1,1] +Output: [1,-1] +Explanation: +1 is the only positive integer and -1 the only negative integer in nums. +So nums is rearranged to [1,-1]. ++ +
+
Constraints:
+ +2 <= nums.length <= 2 * 105nums.length is even1 <= |nums[i]| <= 105nums consists of equal number of positive and negative integers.Input: text = " this is a sentence " Output: "this is a sentence" -Explanation: There are a total of 9 spaces and 4 words. We can evenly divide the 9 spaces between the words: 9 / (4-1) = 3 spaces. +Explanation: There are a total of 9 spaces and 4 words. We can evenly divide the 9 spaces between the words: 9 / (4-1) = 3 spaces.
Example 2:
@@ -31,28 +31,7 @@Input: text = " practice makes perfect" Output: "practice makes perfect " -Explanation: There are a total of 7 spaces and 3 words. 7 / (3-1) = 3 spaces plus 1 extra space. We place this extra space at the end of the string. -- -
Example 3:
- --Input: text = "hello world" -Output: "hello world" -- -
Example 4:
- --Input: text = " walks udp package into bar a" -Output: "walks udp package into bar a " -- -
Example 5:
- --Input: text = "a" -Output: "a" +Explanation: There are a total of 7 spaces and 3 words. 7 / (3-1) = 3 spaces plus 1 extra space. We place this extra space at the end of the string.
@@ -60,13 +39,16 @@
1 <= text.length <= 100text consists of lowercase English letters and ' '.text contains at least one word.text consists of lowercase English letters and ' '.text contains at least one word.Alice had a 0-indexed array arr consisting of n positive integers. She chose an arbitrary positive integer k and created two new 0-indexed integer arrays lower and higher in the following manner:
lower[i] = arr[i] - k, for every index i where 0 <= i < nhigher[i] = arr[i] + k, for every index i where 0 <= i < nUnfortunately, Alice lost all three arrays. However, she remembers the integers that were present in the arrays lower and higher, but not the array each integer belonged to. Help Alice and recover the original array.
Given an array nums consisting of 2n integers, where exactly n of the integers were present in lower and the remaining in higher, return the original array arr. In case the answer is not unique, return any valid array.
Note: The test cases are generated such that there exists at least one valid array arr.
+
Example 1:
+ ++Input: nums = [2,10,6,4,8,12] +Output: [3,7,11] +Explanation: +If arr = [3,7,11] and k = 1, we get lower = [2,6,10] and higher = [4,8,12]. +Combining lower and higher gives us [2,6,10,4,8,12], which is a permutation of nums. +Another valid possibility is that arr = [5,7,9] and k = 3. In that case, lower = [2,4,6] and higher = [8,10,12]. ++ +
Example 2:
+ ++Input: nums = [1,1,3,3] +Output: [2,2] +Explanation: +If arr = [2,2] and k = 1, we get lower = [1,1] and higher = [3,3]. +Combining lower and higher gives us [1,1,3,3], which is equal to nums. +Note that arr cannot be [1,3] because in that case, the only possible way to obtain [1,1,3,3] is with k = 0. +This is invalid since k must be positive. ++ +
Example 3:
+ ++Input: nums = [5,435] +Output: [220] +Explanation: +The only possible combination is arr = [220] and k = 215. Using them, we get lower = [5] and higher = [435]. ++ +
+
Constraints:
+ +2 * n == nums.length1 <= n <= 10001 <= nums[i] <= 109arr.Example 2:
@@ -34,40 +34,19 @@ Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] Explanation: The only possible set you can choose is {7}. This will make the new array empty. -Example 3:
- --Input: arr = [1,9] -Output: 1 -- -
Example 4:
- --Input: arr = [1000,1000,3,7] -Output: 1 -- -
Example 5:
- --Input: arr = [1,2,3,4,5,6,7,8,9,10] -Output: 5 --
Constraints:
1 <= arr.length <= 1052 <= arr.length <= 105arr.length is even.1 <= arr[i] <= 105Input: satisfaction = [-1,-4,-5] Output: 0 -Explanation: People don't like the dishes. No dish is prepared. -- -
Example 4:
- --Input: satisfaction = [-2,5,-1,0,3,-3] -Output: 35 +Explanation: People do not like the dishes. No dish is prepared.
@@ -61,9 +54,9 @@ Each dish is prepared in one unit of time. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/reformat-phone-number/README.md b/problems/reformat-phone-number/README.md index 0ee2dbf14..d4dc85908 100644 --- a/problems/reformat-phone-number/README.md +++ b/problems/reformat-phone-number/README.md @@ -60,26 +60,12 @@ Step 3: There are 2 digits left, so put them in a single block of length 2. The Joining the blocks gives "123-456-78". -
Example 4:
- --Input: number = "12" -Output: "12" -- -
Example 5:
- --Input: number = "--17-5 229 35-39475 " -Output: "175-229-353-94-75" --
Constraints:
2 <= number.length <= 100number consists of digits and the characters '-' and ' '.number consists of digits and the characters '-' and ' '.number.Input: intervals = [[1,4],[3,6],[2,8]] Output: 2 -Explanation: Interval [3,6] is covered by [2,8], therefore it is removed. +Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.
Example 2:
@@ -33,27 +33,6 @@ Output: 1 -Example 3:
- --Input: intervals = [[0,10],[5,12]] -Output: 2 -- -
Example 4:
- --Input: intervals = [[3,10],[4,10],[5,11]] -Output: 2 -- -
Example 5:
- --Input: intervals = [[1,2],[1,4],[3,4]] -Output: 1 --
Constraints:
diff --git a/problems/remove-interval/README.md b/problems/remove-interval/README.md index 89f6001a6..bce96a0c0 100644 --- a/problems/remove-interval/README.md +++ b/problems/remove-interval/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../hexspeak "Hexspeak") diff --git a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md index 2073e3fc8..11e59e27d 100644 --- a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md +++ b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md @@ -5,7 +5,7 @@ -[< Previous](../minimum-deletion-cost-to-avoid-repeating-letters "Minimum Deletion Cost to Avoid Repeating Letters") +[< Previous](../minimum-time-to-make-rope-colorful "Minimum Time to Make Rope Colorful") [Next >](../put-boxes-into-the-warehouse-ii "Put Boxes Into the Warehouse II") diff --git a/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md b/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md index c8499e554..2a1183730 100644 --- a/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md +++ b/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md @@ -46,14 +46,6 @@ No resulting array is strictly increasing, so return false. [1,1] is not strictly increasing, so return false. -Example 4:
- --Input: nums = [1,2,3] -Output: true -Explanation: [1,2,3] is already strictly increasing, so return true. --
Constraints:
diff --git a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md index 239cd5e5b..674f758f7 100644 --- a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md +++ b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md @@ -52,6 +52,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] +### Similar Questions + 1. [Delete N Nodes After M Nodes of a Linked List](../delete-n-nodes-after-m-nodes-of-a-linked-list) (Easy) + ### HintsYou are given a 0-indexed array of distinct integers nums.
There is an element in nums that has the lowest value and an element that has the highest value. We call them the minimum and maximum respectively. Your goal is to remove both these elements from the array.
A deletion is defined as either removing an element from the front of the array or removing an element from the back of the array.
+ +Return the minimum number of deletions it would take to remove both the minimum and maximum element from the array.
+ ++
Example 1:
+ ++Input: nums = [2,10,7,5,4,1,8,6] +Output: 5 +Explanation: +The minimum element in the array is nums[5], which is 1. +The maximum element in the array is nums[1], which is 10. +We can remove both the minimum and maximum by removing 2 elements from the front and 3 elements from the back. +This results in 2 + 3 = 5 deletions, which is the minimum number possible. ++ +
Example 2:
+ ++Input: nums = [0,-4,19,1,8,-2,-3,5] +Output: 3 +Explanation: +The minimum element in the array is nums[1], which is -4. +The maximum element in the array is nums[2], which is 19. +We can remove both the minimum and maximum by removing 3 elements from the front. +This results in only 3 deletions, which is the minimum number possible. ++ +
Example 3:
+ ++Input: nums = [101] +Output: 1 +Explanation: +There is only one element in the array, which makes it both the minimum and maximum element. +We can remove it with 1 deletion. ++ +
+
Constraints:
+ +1 <= nums.length <= 105-105 <= nums[i] <= 105nums are distinct.You are given an array of positive integers beans, where each integer represents the number of magic beans found in a particular magic bag.
Remove any number of beans (possibly none) from each bag such that the number of beans in each remaining non-empty bag (still containing at least one bean) is equal. Once a bean has been removed from a bag, you are not allowed to return it to any of the bags.
+ +Return the minimum number of magic beans that you have to remove.
+ ++
Example 1:
+ ++Input: beans = [4,1,6,5] +Output: 4 +Explanation: +- We remove 1 bean from the bag with only 1 bean. + This results in the remaining bags: [4,0,6,5] +- Then we remove 2 beans from the bag with 6 beans. + This results in the remaining bags: [4,0,4,5] +- Then we remove 1 bean from the bag with 5 beans. + This results in the remaining bags: [4,0,4,4] +We removed a total of 1 + 2 + 1 = 4 beans to make the remaining non-empty bags have an equal number of beans. +There are no other solutions that remove 4 beans or fewer. ++ +
Example 2:
+ ++Input: beans = [2,10,3,2] +Output: 7 +Explanation: +- We remove 2 beans from one of the bags with 2 beans. + This results in the remaining bags: [0,10,3,2] +- Then we remove 2 beans from the other bag with 2 beans. + This results in the remaining bags: [0,10,3,0] +- Then we remove 3 beans from the bag with 3 beans. + This results in the remaining bags: [0,10,0,0] +We removed a total of 2 + 2 + 3 = 7 beans to make the remaining non-empty bags have an equal number of beans. +There are no other solutions that removes 7 beans or fewer. ++ +
+
Constraints:
+ +1 <= beans.length <= 1051 <= beans[i] <= 105Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b to be a substring of a after repeating it, return -1.
Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b to be a substring of a after repeating it, return -1.
Notice: string "abc" repeated 0 times is "", repeated 1 time is "abc" and repeated 2 times is "abcabc".
Notice: string "abc" repeated 0 times is "", repeated 1 time is "abc" and repeated 2 times is "abcabc".
Example 1:
@@ -31,27 +31,12 @@ Output: 2 -Example 3:
- --Input: a = "a", b = "a" -Output: 1 -- -
Example 4:
- --Input: a = "abc", b = "wxyz" -Output: -1 --
Constraints:
1 <= a.length <= 1041 <= b.length <= 104a and b consist of lower-case English letters.1 <= a.length, b.length <= 104a and b consist of lowercase English letters.Input: s = "?zs" Output: "azs" -Explanation: There are 25 solutions for this problem. From "azs" to "yzs", all are valid. Only "z" is an invalid modification as the string will consist of consecutive repeating characters in "zzs".+Explanation: There are 25 solutions for this problem. From "azs" to "yzs", all are valid. Only "z" is an invalid modification as the string will consist of consecutive repeating characters in "zzs". +
Example 2:
Input: s = "ubv?w" Output: "ubvaw" -Explanation: There are 24 solutions for this problem. Only "v" and "w" are invalid modifications as the strings will consist of consecutive repeating characters in "ubvvw" and "ubvww". -- -
Example 3:
- --Input: s = "j?qg??b" -Output: "jaqgacb" -- -
Example 4:
- --Input: s = "??yw?ipkj?" -Output: "acywaipkja" +Explanation: There are 24 solutions for this problem. Only "v" and "w" are invalid modifications as the strings will consist of consecutive repeating characters in "ubvvw" and "ubvww".
diff --git a/problems/reported-posts-ii/README.md b/problems/reported-posts-ii/README.md index b14a7515b..bd1a28b4e 100644 --- a/problems/reported-posts-ii/README.md +++ b/problems/reported-posts-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-of-absolute-value-expression "Maximum of Absolute Value Expression") diff --git a/problems/restore-the-array/README.md b/problems/restore-the-array/README.md index 570dbce5a..caa50f9a9 100644 --- a/problems/restore-the-array/README.md +++ b/problems/restore-the-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "The k-th Lexicographical String of All Happy Strings of Length n") @@ -40,21 +40,6 @@ Explanation: Possible arrays are [1317],[131,7],[13,17],[1,317],[13,1,7],[1,31,7],[1,3,17],[1,3,1,7] -
Example 4:
- --Input: s = "2020", k = 30 -Output: 1 -Explanation: The only possible array is [20,20]. [2020] is invalid because 2020 > 30. [2,020] is ivalid because 020 contains leading zeros. -- -
Example 5:
- --Input: s = "1234567890", k = 90 -Output: 34 --
Constraints:
@@ -68,6 +53,9 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Number of Ways to Separate Numbers](../number-of-ways-to-separate-numbers) (Hard) + ### HintsFollow up: If this function is called many times, how would you optimize it?
### Related Topics - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions 1. [Reverse Integer](../reverse-integer) (Medium) diff --git a/problems/reverse-linked-list/README.md b/problems/reverse-linked-list/README.md index 393cdb8d1..be9956cae 100644 --- a/problems/reverse-linked-list/README.md +++ b/problems/reverse-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../isomorphic-strings "Isomorphic Strings") @@ -47,10 +47,12 @@Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both?
### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Reverse Linked List II](../reverse-linked-list-ii) (Medium) 1. [Binary Tree Upside Down](../binary-tree-upside-down) (Medium) 1. [Palindrome Linked List](../palindrome-linked-list) (Easy) + 1. [Reverse Nodes in Even Length Groups](../reverse-nodes-in-even-length-groups) (Medium) + 1. [Maximum Twin Sum of a Linked List](../maximum-twin-sum-of-a-linked-list) (Medium) diff --git a/problems/reverse-nodes-in-even-length-groups/README.md b/problems/reverse-nodes-in-even-length-groups/README.md index 1acbfaf3b..ff39ee8c6 100644 --- a/problems/reverse-nodes-in-even-length-groups/README.md +++ b/problems/reverse-nodes-in-even-length-groups/README.md @@ -32,9 +32,9 @@ Input: head = [5,2,6,3,9,1,7,3,8,4] Output: [5,6,2,3,9,1,4,8,3,7] Explanation: -- The length of the first group is 1, which is odd, hence no reversal occurrs. +- The length of the first group is 1, which is odd, hence no reversal occurs. - The length of the second group is 2, which is even, hence the nodes are reversed. -- The length of the third group is 3, which is odd, hence no reversal occurrs. +- The length of the third group is 3, which is odd, hence no reversal occurs. - The length of the last group is 4, which is even, hence the nodes are reversed. @@ -44,9 +44,9 @@ Input: head = [1,1,0,6] Output: [1,0,1,6] Explanation: -- The length of the first group is 1. No reversal occurrs. +- The length of the first group is 1. No reversal occurs. - The length of the second group is 2. The nodes are reversed. -- The length of the last group is 1. No reversal occurrs. +- The length of the last group is 1. No reversal occurs.Example 3:
@@ -55,29 +55,11 @@ Input: head = [1,1,0,6,5] Output: [1,0,1,5,6] Explanation: -- The length of the first group is 1. No reversal occurrs. +- The length of the first group is 1. No reversal occurs. - The length of the second group is 2. The nodes are reversed. - The length of the last group is 2. The nodes are reversed. -Example 4:
-
--Input: head = [2,1] -Output: [2,1] -Explanation: -- The length of the first group is 1. No reversal occurrs. -- The length of the last group is 1. No reversal occurrs. -- -
Example 5:
- --Input: head = [8] -Output: [8] -Explanation: There is only one group whose length is 1. No reversal occurrs. --
Constraints:
diff --git a/problems/reverse-words-in-a-string/README.md b/problems/reverse-words-in-a-string/README.md index a42fabf98..0a2002fd0 100644 --- a/problems/reverse-words-in-a-string/README.md +++ b/problems/reverse-words-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../evaluate-reverse-polish-notation "Evaluate Reverse Polish Notation") @@ -43,20 +43,6 @@ Explanation: You need to reduce multiple spaces between two words to a single space in the reversed string. -Example 4:
- --Input: s = " Bob Loves Alice " -Output: "Alice Loves Bob" -- -
Example 5:
- --Input: s = "Alice does not even like bob" -Output: "bob like even not does Alice" --
Constraints:
diff --git a/problems/rings-and-rods/README.md b/problems/rings-and-rods/README.md new file mode 100644 index 000000000..3944e5b9c --- /dev/null +++ b/problems/rings-and-rods/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../sequentially-ordinal-rank-tracker "Sequentially Ordinal Rank Tracker") + +[Next >](../sum-of-subarray-ranges "Sum of Subarray Ranges") + +## [2103. Rings and Rods (Easy)](https://leetcode.com/problems/rings-and-rods "环和杆") + +There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9.
You are given a string rings of length 2n that describes the n rings that are placed onto the rods. Every two characters in rings forms a color-position pair that is used to describe each ring where:
ith pair denotes the ith ring's color ('R', 'G', 'B').ith pair denotes the rod that the ith ring is placed on ('0' to '9').For example, "R3G2B1" describes n == 3 rings: a red ring placed onto the rod labeled 3, a green ring placed onto the rod labeled 2, and a blue ring placed onto the rod labeled 1.
Return the number of rods that have all three colors of rings on them.
+ ++
Example 1:
+
++Input: rings = "B0B6G0R6R0R6G9" +Output: 1 +Explanation: +- The rod labeled 0 holds 3 rings with all colors: red, green, and blue. +- The rod labeled 6 holds 3 rings, but it only has red and blue. +- The rod labeled 9 holds only a green ring. +Thus, the number of rods with all three colors is 1. ++ +
Example 2:
+
++Input: rings = "B0R0G0R9R0B0G0" +Output: 1 +Explanation: +- The rod labeled 0 holds 6 rings with all colors: red, green, and blue. +- The rod labeled 9 holds only a red ring. +Thus, the number of rods with all three colors is 1. ++ +
Example 3:
+ ++Input: rings = "G4" +Output: 0 +Explanation: +Only one ring is given. Thus, no rods have all three colors. ++ +
+
Constraints:
+ +rings.length == 2 * n1 <= n <= 100rings[i] where i is even is either 'R', 'G', or 'B' (0-indexed).rings[i] where i is odd is a digit from '0' to '9' (0-indexed).Given an array, rotate the array to the right by k steps, where k is non-negative.
Constraints:
1 <= envelopes.length <= 50001 <= envelopes.length <= 105envelopes[i].length == 21 <= wi, hi <= 1041 <= wi, hi <= 105
Example 1:
-Input: nums = [1,3,5,6], target = 5 + +-+Input: nums = [1,3,5,6], target = 5 Output: 2 -Example 2:
-Input: nums = [1,3,5,6], target = 2 ++ +Example 2:
+ ++Input: nums = [1,3,5,6], target = 2 Output: 1 -Example 3:
-Input: nums = [1,3,5,6], target = 7 ++ +Example 3:
+ ++Input: nums = [1,3,5,6], target = 7 Output: 4 -Example 4:
-Input: nums = [1,3,5,6], target = 0 -Output: 0 -Example 5:
-Input: nums = [1], target = 0 -Output: 0+
Constraints:
diff --git a/problems/search-suggestions-system/README.md b/problems/search-suggestions-system/README.md index e572da055..be6fd4f4d 100644 --- a/problems/search-suggestions-system/README.md +++ b/problems/search-suggestions-system/README.md @@ -11,9 +11,11 @@ ## [1268. Search Suggestions System (Medium)](https://leetcode.com/problems/search-suggestions-system "搜索推荐系统") -Given an array of strings
+productsand a stringsearchWord. We want to design a system that suggests at most three product names fromproductsafter each character ofsearchWordis typed. Suggested products should have common prefix with the searchWord. If there are more than three products with a common prefix return the three lexicographically minimums products.You are given an array of strings
-productsand a stringsearchWord.Return list of lists of the suggested
+productsafter each character ofsearchWordis typed.Design a system that suggests at most three product names from
+ +productsafter each character ofsearchWordis typed. Suggested products should have common prefix withsearchWord. If there are more than three products with a common prefix return the three lexicographically minimums products.Return a list of lists of the suggested products after each character of
searchWordis typed.
Example 1:
@@ -46,23 +48,17 @@ After typing mou, mous and mouse the system suggests ["mouse","mo Output: [["baggage","bags","banner"],["baggage","bags","banner"],["baggage","bags"],["bags"]]
Example 4:
- --Input: products = ["havana"], searchWord = "tatiana" -Output: [[],[],[],[],[],[],[]] --
Constraints:
1 <= products.length <= 1000products.1 <= Σ products[i].length <= 2 * 10^4products[i] are lower-case English letters.1 <= products[i].length <= 30001 <= sum(products[i].length) <= 2 * 104products are unique.products[i] consists of lowercase English letters.1 <= searchWord.length <= 1000searchWord are lower-case English letters.searchWord consists of lowercase English letters.Write a SQL query to get the second highest salary from the Employee table.
Table: Employee
++-------------+------+ +| Column Name | Type | ++-------------+------+ +| id | int | +| salary | int | ++-------------+------+ +id is the primary key column for this table. +Each row of this table contains information about the salary of an employee. ++ +
+ +
Write an SQL query to report the second highest salary from the Employee table. If there is no second highest salary, the query should report null.
The query result format is in the following example.
+ ++
Example 1:
+ ++Input: +Employee table: +----+--------+ -| Id | Salary | +| id | salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ +Output: ++---------------------+ +| SecondHighestSalary | ++---------------------+ +| 200 | ++---------------------+-
For example, given the above Employee table, the query should return 200 as the second highest salary. If there is no second highest salary, then the query should return null.
Example 2:
+Input: +Employee table: ++----+--------+ +| id | salary | ++----+--------+ +| 1 | 100 | ++----+--------+ +Output: +---------------------+ | SecondHighestSalary | +---------------------+ -| 200 | +| null | +---------------------+diff --git a/problems/second-highest-salary/mysql_schemas.sql b/problems/second-highest-salary/mysql_schemas.sql index c08cc8bd5..f98a8511a 100644 --- a/problems/second-highest-salary/mysql_schemas.sql +++ b/problems/second-highest-salary/mysql_schemas.sql @@ -1,5 +1,5 @@ -Create table If Not Exists Employee (Id int, Salary int); +Create table If Not Exists Employee (id int, salary int); Truncate table Employee; -insert into Employee (Id, Salary) values ('1', '100'); -insert into Employee (Id, Salary) values ('2', '200'); -insert into Employee (Id, Salary) values ('3', '300'); +insert into Employee (id, salary) values ('1', '100'); +insert into Employee (id, salary) values ('2', '200'); +insert into Employee (id, salary) values ('3', '300'); diff --git a/problems/second-minimum-time-to-reach-destination/README.md b/problems/second-minimum-time-to-reach-destination/README.md index b6cd23da1..6511ed733 100644 --- a/problems/second-minimum-time-to-reach-destination/README.md +++ b/problems/second-minimum-time-to-reach-destination/README.md @@ -80,7 +80,6 @@ The second minimum time path is 1 -> 2 -> 1 -> 2 with time = 11 minutes ### Related Topics [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Array](../../tag/array/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] ### Hints diff --git a/problems/self-crossing/README.md b/problems/self-crossing/README.md index fdf7c5d0b..39f96b944 100644 --- a/problems/self-crossing/README.md +++ b/problems/self-crossing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../increasing-triplet-subsequence "Increasing Triplet Subsequence") diff --git a/problems/sell-diminishing-valued-colored-balls/README.md b/problems/sell-diminishing-valued-colored-balls/README.md index 4f26b0d86..e010dd174 100644 --- a/problems/sell-diminishing-valued-colored-balls/README.md +++ b/problems/sell-diminishing-valued-colored-balls/README.md @@ -38,21 +38,6 @@ The maximum total value is 2 + 5 + 4 + 3 = 14. The maximum total value is 3 + 2 + 5 + 4 + 3 + 2 = 19. -
Example 3:
- --Input: inventory = [2,8,4,10,6], orders = 20 -Output: 110 -- -
Example 4:
- --Input: inventory = [1000000000], orders = 1000000000 -Output: 21 -Explanation: Sell the 1st color 1000000000 times for a total value of 500000000500000000. 500000000500000000 modulo 109 + 7 = 21. --
Constraints:
diff --git a/problems/sentence-similarity-iii/README.md b/problems/sentence-similarity-iii/README.md index 02839ffad..45db111c7 100644 --- a/problems/sentence-similarity-iii/README.md +++ b/problems/sentence-similarity-iii/README.md @@ -42,13 +42,6 @@ Explanation: sentence2 can be turned to sentence1 by inserting "right now" at the end of the sentence. -Example 4:
- --Input: sentence1 = "Luky", sentence2 = "Lucccky" -Output: false --
Constraints:
diff --git a/problems/sequentially-ordinal-rank-tracker/README.md b/problems/sequentially-ordinal-rank-tracker/README.md new file mode 100644 index 000000000..4b1402419 --- /dev/null +++ b/problems/sequentially-ordinal-rank-tracker/README.md @@ -0,0 +1,113 @@ + + + + + + + +[< Previous](../detonate-the-maximum-bombs "Detonate the Maximum Bombs") + +[Next >](../rings-and-rods "Rings and Rods") + +## [2102. Sequentially Ordinal Rank Tracker (Hard)](https://leetcode.com/problems/sequentially-ordinal-rank-tracker "序列顺序查询") + +A scenic location is represented by its name and attractiveness score, where name is a unique string among all locations and score is an integer. Locations can be ranked from the best to the worst. The higher the score, the better the location. If the scores of two locations are equal, then the location with the lexicographically smaller name is better.
You are building a system that tracks the ranking of locations with the system initially starting with no locations. It supports:
+ +ith best location of all locations already added, where i is the number of times the system has been queried (including the current query).
+ 4th time, it returns the 4th best location of all locations already added.Note that the test data are generated so that at any time, the number of queries does not exceed the number of locations added to the system.
+ +Implement the SORTracker class:
SORTracker() Initializes the tracker system.void add(string name, int score) Adds a scenic location with name and score to the system.string get() Queries and returns the ith best location, where i is the number of times this method has been invoked (including this invocation).+
Example 1:
+ +
+Input
+["SORTracker", "add", "add", "get", "add", "get", "add", "get", "add", "get", "add", "get", "get"]
+[[], ["bradford", 2], ["branford", 3], [], ["alps", 2], [], ["orland", 2], [], ["orlando", 3], [], ["alpine", 2], [], []]
+Output
+[null, null, null, "branford", null, "alps", null, "bradford", null, "bradford", null, "bradford", "orland"]
+
+Explanation
+SORTracker tracker = new SORTracker(); // Initialize the tracker system.
+tracker.add("bradford", 2); // Add location with name="bradford" and score=2 to the system.
+tracker.add("branford", 3); // Add location with name="branford" and score=3 to the system.
+tracker.get(); // The sorted locations, from best to worst, are: branford, bradford.
+ // Note that branford precedes bradford due to its higher score (3 > 2).
+ // This is the 1st time get() is called, so return the best location: "branford".
+tracker.add("alps", 2); // Add location with name="alps" and score=2 to the system.
+tracker.get(); // Sorted locations: branford, alps, bradford.
+ // Note that alps precedes bradford even though they have the same score (2).
+ // This is because "alps" is lexicographically smaller than "bradford".
+ // Return the 2nd best location "alps", as it is the 2nd time get() is called.
+tracker.add("orland", 2); // Add location with name="orland" and score=2 to the system.
+tracker.get(); // Sorted locations: branford, alps, bradford, orland.
+ // Return "bradford", as it is the 3rd time get() is called.
+tracker.add("orlando", 3); // Add location with name="orlando" and score=3 to the system.
+tracker.get(); // Sorted locations: branford, orlando, alps, bradford, orland.
+ // Return "bradford".
+tracker.add("alpine", 2); // Add location with name="alpine" and score=2 to the system.
+tracker.get(); // Sorted locations: branford, orlando, alpine, alps, bradford, orland.
+ // Return "bradford".
+tracker.get(); // Sorted locations: branford, orlando, alpine, alps, bradford, orland.
+ // Return "orland".
+
+
++
Constraints:
+ +name consists of lowercase English letters, and is unique among all locations.1 <= name.length <= 101 <= score <= 105get does not exceed the number of calls to add.4 * 104 calls in total will be made to add and get.Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's, and return the matrix.
Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's.
You must do it in place.
@@ -56,6 +56,8 @@ ### Similar Questions 1. [Game of Life](../game-of-life) (Medium) + 1. [Number of Laser Beams in a Bank](../number-of-laser-beams-in-a-bank) (Medium) + 1. [Minimum Operations to Remove Adjacent Ones in Matrix](../minimum-operations-to-remove-adjacent-ones-in-matrix) (Hard) ### HintsIn a given 2D binary array grid, there are two islands. (An island is a 4-directionally connected group of 1s not connected to any other 1s.)
You are given an n x n binary matrix grid where 1 represents land and 0 represents water.
Now, we may change 0s to 1s so as to connect the two islands together to form 1 island.
An island is a 4-directionally connected group of 1's not connected to any other 1's. There are exactly two islands in grid.
Return the smallest number of 0s that must be flipped. (It is guaranteed that the answer is at least 1.)
You may change 0's to 1's to connect the two islands to form one island.
Return the smallest number of 0's you must flip to connect the two islands.
Example 1:
@@ -43,8 +45,10 @@Constraints:
2 <= grid.length == grid[0].length <= 100grid[i][j] == 0 or grid[i][j] == 1n == grid.length == grid[i].length2 <= n <= 100grid[i][j] is either 0 or 1.grid.Example 3:
- --Input: licensePlate = "Ah71752", words = ["suggest","letter","of","husband","easy","education","drug","prevent","writer","old"] -Output: "husband" -- -
Example 4:
- --Input: licensePlate = "OgEu755", words = ["enough","these","play","wide","wonder","box","arrive","money","tax","thus"] -Output: "enough" -- -
Example 5:
- --Input: licensePlate = "iMSlpe4", words = ["claim","consumer","student","camera","public","never","wonder","simple","thought","use"] -Output: "simple" --
Constraints:
@@ -74,6 +53,7 @@ Since "steps" is the only word containing all the letters, that is the ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/shortest-distance-from-all-buildings/README.md b/problems/shortest-distance-from-all-buildings/README.md index ee20e154f..d8508700c 100644 --- a/problems/shortest-distance-from-all-buildings/README.md +++ b/problems/shortest-distance-from-all-buildings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicate-letters "Remove Duplicate Letters") diff --git a/problems/shortest-path-in-a-hidden-grid/README.md b/problems/shortest-path-in-a-hidden-grid/README.md index 9a8aae6c9..c519f5a97 100644 --- a/problems/shortest-path-in-a-hidden-grid/README.md +++ b/problems/shortest-path-in-a-hidden-grid/README.md @@ -19,6 +19,10 @@ [[Graph](../../tag/graph/README.md)] [[Interactive](../../tag/interactive/README.md)] +### Similar Questions + 1. [Robot Room Cleaner](../robot-room-cleaner) (Hard) + 1. [Minimum Path Cost in a Hidden Grid](../minimum-path-cost-in-a-hidden-grid) (Medium) + ### HintsInput: arr = [1,2,3,10,4,2,3,5] Output: 3 -Explanation: The shortest subarray we can remove is [10,4,2] of length 3. The remaining elements after that will be [1,2,3,3,5] which are sorted. -Another correct solution is to remove the subarray [3,10,4].+Explanation: The shortest subarray we can remove is [10,4,2] of length 3. The remaining elements after that will be [1,2,3,3,5] which are sorted. +Another correct solution is to remove the subarray [3,10,4]. +
Example 2:
Input: arr = [5,4,3,2,1] Output: 4 -Explanation: Since the array is strictly decreasing, we can only keep a single element. Therefore we need to remove a subarray of length 4, either [5,4,3,2] or [4,3,2,1]. +Explanation: Since the array is strictly decreasing, we can only keep a single element. Therefore we need to remove a subarray of length 4, either [5,4,3,2] or [4,3,2,1].
Example 3:
@@ -39,14 +40,7 @@ Another correct solution is to remove the subarray [3,10,4].Input: arr = [1,2,3] Output: 0 -Explanation: The array is already non-decreasing. We do not need to remove any elements. -- -
Example 4:
- --Input: arr = [1] -Output: 0 +Explanation: The array is already non-decreasing. We do not need to remove any elements.
@@ -58,10 +52,10 @@ Another correct solution is to remove the subarray [3,10,4]. ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Stack](../../tag/stack/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints diff --git a/problems/shortest-way-to-form-string/README.md b/problems/shortest-way-to-form-string/README.md index 6a522ebee..2a8fb3a4b 100644 --- a/problems/shortest-way-to-form-string/README.md +++ b/problems/shortest-way-to-form-string/README.md @@ -51,13 +51,12 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Is Subsequence](../is-subsequence) (Easy) - 1. [Number of Matching Subsequences](../number-of-matching-subsequences) (Medium) ### Hints
Given a string s and an integer array indices of the same length.
The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.
You are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.
Return the shuffled string.
@@ -34,36 +32,15 @@ Explanation: After shuffling, each character remains in its position. -Example 3:
- -
-Input: s = "aiohn", indices = [3,1,4,2,0]
-Output: "nihao"
-
-
-Example 4:
- -
-Input: s = "aaiougrt", indices = [4,0,2,6,7,3,1,5]
-Output: "arigatou"
-
-
-Example 5:
- -
-Input: s = "art", indices = [1,0,2]
-Output: "rat"
-
-
Constraints:
s.length == indices.length == n1 <= n <= 100s contains only lower-case English letters.0 <= indices[i] < nindices are unique (i.e. indices is a permutation of the integers from 0 to n - 1).s consists of only lowercase English letters.0 <= indices[i] < nindices are unique.Input: path = "/home//foo/" Output: "/home/foo" -Explanation: In the canonical path, multiple consecutive slashes are replaced by a single one. -- -
Example 4:
- --Input: path = "/a/./b/../../c/" -Output: "/c" +Explanation: In the canonical path, multiple consecutive slashes are replaced by a single one.
diff --git a/problems/single-row-keyboard/README.md b/problems/single-row-keyboard/README.md index dabe10b72..37330813a 100644 --- a/problems/single-row-keyboard/README.md +++ b/problems/single-row-keyboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../product-price-at-a-given-date "Product Price at a Given Date") diff --git a/problems/smallest-greater-multiple-made-of-two-digits/README.md b/problems/smallest-greater-multiple-made-of-two-digits/README.md index 2b62f9d3f..cd7e4bd7f 100644 --- a/problems/smallest-greater-multiple-made-of-two-digits/README.md +++ b/problems/smallest-greater-multiple-made-of-two-digits/README.md @@ -9,7 +9,7 @@ [Next >](../reverse-prefix-of-word "Reverse Prefix of Word") -## [1999. Smallest Greater Multiple Made of Two Digits (Medium)](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits "") +## [1999. Smallest Greater Multiple Made of Two Digits (Medium)](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits "最小的仅由两个数组成的倍数") diff --git a/problems/smallest-index-with-equal-value/README.md b/problems/smallest-index-with-equal-value/README.md index 580d8f059..48843d83d 100644 --- a/problems/smallest-index-with-equal-value/README.md +++ b/problems/smallest-index-with-equal-value/README.md @@ -49,14 +49,6 @@ i=3: 3 mod 10 = 3 != nums[3]. Explanation: No index satisfies i mod 10 == nums[i]. -
Example 4:
- --Input: nums = [2,1,3,5,2] -Output: 1 -Explanation: 1 is the only index with i mod 10 == nums[i]. --
Constraints:
diff --git a/problems/smallest-range-covering-elements-from-k-lists/README.md b/problems/smallest-range-covering-elements-from-k-lists/README.md index c6b732dd2..7738b24d9 100644 --- a/problems/smallest-range-covering-elements-from-k-lists/README.md +++ b/problems/smallest-range-covering-elements-from-k-lists/README.md @@ -34,27 +34,6 @@ List 3: [5, 18, 22, 30], 22 is in range [20,24]. Output: [1,1] -Example 3:
- --Input: nums = [[10,10],[11,11]] -Output: [10,11] -- -
Example 4:
- --Input: nums = [[10],[11]] -Output: [10,11] -- -
Example 5:
- --Input: nums = [[1],[2],[3],[4],[5],[6],[7]] -Output: [1,7] --
Constraints:
@@ -67,9 +46,12 @@ List 3: [5, 18, 22, 30], 22 is in range [20,24]. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Sorting](../../tag/sorting/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Similar Questions + 1. [Minimum Window Substring](../minimum-window-substring) (Hard) diff --git a/problems/smallest-string-starting-from-leaf/README.md b/problems/smallest-string-starting-from-leaf/README.md index 2cacbb7f1..9b0831735 100644 --- a/problems/smallest-string-starting-from-leaf/README.md +++ b/problems/smallest-string-starting-from-leaf/README.md @@ -54,9 +54,9 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md index 8c29362be..f7479d7cc 100644 --- a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md +++ b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-to-get-all-keys "Shortest Path to Get All Keys") @@ -15,11 +15,9 @@Return the smallest subtree such that it contains all the deepest nodes in the original tree.
-A node is called the deepest if it has the largest depth possible among any node in the entire tree.
+A node is called the deepest if it has the largest depth possible among any node in the entire tree.
-The subtree of a node is tree consisting of that node, plus the set of all descendants of that node.
- -Note: This question is the same as 1123: https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/
+The subtree of a node is a tree consisting of that node, plus the set of all descendants of that node.
Example 1:
@@ -54,12 +52,15 @@ Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is[1, 500].0 <= Node.val <= 500+
Note: This question is the same as 1123: https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/
+ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/smallest-value-of-the-rearranged-number/README.md b/problems/smallest-value-of-the-rearranged-number/README.md new file mode 100644 index 000000000..3d029d147 --- /dev/null +++ b/problems/smallest-value-of-the-rearranged-number/README.md @@ -0,0 +1,59 @@ + + + + + + + +[< Previous](../sort-even-and-odd-indices-independently "Sort Even and Odd Indices Independently") + +[Next >](../design-bitset "Design Bitset") + +## [2165. Smallest Value of the Rearranged Number (Medium)](https://leetcode.com/problems/smallest-value-of-the-rearranged-number "重排数字的最小值") + +You are given an integer num. Rearrange the digits of num such that its value is minimized and it does not contain any leading zeros.
Return the rearranged number with minimal value.
+ +Note that the sign of the number does not change after rearranging the digits.
+ ++
Example 1:
+ ++Input: num = 310 +Output: 103 +Explanation: The possible arrangements for the digits of 310 are 013, 031, 103, 130, 301, 310. +The arrangement with the smallest value that does not contain any leading zeros is 103. ++ +
Example 2:
+ ++Input: num = -7605 +Output: -7650 +Explanation: Some possible arrangements for the digits of -7605 are -7650, -6705, -5076, -0567. +The arrangement with the smallest value that does not contain any leading zeros is -7650. ++ +
+
Constraints:
+ +-1015 <= num <= 1015You are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri].
The array describes the questions of an exam, where you have to process the questions in order (i.e., starting from question 0) and make a decision whether to solve or skip each question. Solving question i will earn you pointsi points but you will be unable to solve each of the next brainpoweri questions. If you skip question i, you get to make the decision on the next question.
questions = [[3, 2], [4, 3], [4, 4], [2, 5]]:
+ 0 is solved, you will earn 3 points but you will be unable to solve questions 1 and 2.0 is skipped and question 1 is solved, you will earn 4 points but you will be unable to solve questions 2 and 3.Return the maximum points you can earn for the exam.
+ ++
Example 1:
+ ++Input: questions = [[3,2],[4,3],[4,4],[2,5]] +Output: 5 +Explanation: The maximum points can be earned by solving questions 0 and 3. +- Solve question 0: Earn 3 points, will be unable to solve the next 2 questions +- Unable to solve questions 1 and 2 +- Solve question 3: Earn 2 points +Total points earned: 3 + 2 = 5. There is no other way to earn 5 or more points. ++ +
Example 2:
+ ++Input: questions = [[1,1],[2,2],[3,3],[4,4],[5,5]] +Output: 7 +Explanation: The maximum points can be earned by solving questions 1 and 4. +- Skip question 0 +- Solve question 1: Earn 2 points, will be unable to solve the next 2 questions +- Unable to solve questions 2 and 3 +- Solve question 4: Earn 5 points +Total points earned: 2 + 5 = 7. There is no other way to earn 7 or more points. ++ +
+
Constraints:
+ +1 <= questions.length <= 105questions[i].length == 21 <= pointsi, brainpoweri <= 105You are given a 0-indexed integer array nums. Rearrange the values of nums according to the following rules:
nums in non-increasing order.
+ nums = [4,1,2,3] before this step, it becomes [4,3,2,1] after. The values at odd indices 1 and 3 are sorted in non-increasing order.nums in non-decreasing order.
+ nums = [4,1,2,3] before this step, it becomes [2,1,4,3] after. The values at even indices 0 and 2 are sorted in non-decreasing order.Return the array formed after rearranging the values of nums.
+
Example 1:
+ ++Input: nums = [4,1,2,3] +Output: [2,3,4,1] +Explanation: +First, we sort the values present at odd indices (1 and 3) in non-increasing order. +So, nums changes from [4,1,2,3] to [4,3,2,1]. +Next, we sort the values present at even indices (0 and 2) in non-decreasing order. +So, nums changes from [4,1,2,3] to [2,3,4,1]. +Thus, the array formed after rearranging the values is [2,3,4,1]. ++ +
Example 2:
+ ++Input: nums = [2,1] +Output: [2,1] +Explanation: +Since there is exactly one odd index and one even index, no rearrangement of values takes place. +The resultant array formed is [2,1], which is the same as the initial array. ++ +
+
Constraints:
+ +1 <= nums.length <= 1001 <= nums[i] <= 100Given an integer array arr. You have to sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.
You are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.
Return the sorted array.
+Return the array after sorting it.
Example 1:
@@ -36,33 +36,12 @@ The sorted array by bits is [0,1,2,4,8,3,5,6,7] Explantion: All integers have 1 bit in the binary representation, you should just sort them in ascending order. -Example 3:
- --Input: arr = [10000,10000] -Output: [10000,10000] -- -
Example 4:
- --Input: arr = [2,3,5,7,11,13,17,19] -Output: [2,3,5,17,7,11,13,19] -- -
Example 5:
- --Input: arr = [10,100,1000,10000] -Output: [10,100,10000,1000] --
Constraints:
1 <= arr.length <= 5000 <= arr[i] <= 10^40 <= arr[i] <= 104The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:
The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:
x is even then x = x / 2x is odd then x = 3 * x + 1For example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).
+For example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).
Given three integers lo, hi and k. The task is to sort all integers in the interval [lo, hi] by the power value in ascending order, if two or more integers have the same power value sort them by ascending order.
Return the k-th integer in the range [lo, hi] sorted by the power value.
Return the kth integer in the range [lo, hi] sorted by the power value.
Notice that for any integer x (lo <= x <= hi) it is guaranteed that x will transform into 1 using these steps and that the power of x is will fit in 32 bit signed integer.
Notice that for any integer x (lo <= x <= hi) it is guaranteed that x will transform into 1 using these steps and that the power of x is will fit in a 32-bit signed integer.
Example 1:
@@ -42,13 +42,6 @@ Notice that 12 and 13 have the same power value and we sorted them in ascendingExample 2:
--Input: lo = 1, hi = 1, k = 1 -Output: 1 -- -
Example 3:
-Input: lo = 7, hi = 11, k = 4 Output: 7 @@ -57,20 +50,6 @@ The interval sorted by power is [8, 10, 11, 7, 9]. The fourth number in the sorted array is 7.-
Example 4:
- --Input: lo = 10, hi = 20, k = 5 -Output: 13 -- -
Example 5:
- --Input: lo = 1, hi = 1000, k = 777 -Output: 570 --
Constraints:
@@ -80,8 +59,8 @@ The fourth number in the sorted array is 7. ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Memoization](../../tag/memoization/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/sort-linked-list-already-sorted-using-absolute-values/README.md b/problems/sort-linked-list-already-sorted-using-absolute-values/README.md index 787f6c9e5..452636892 100644 --- a/problems/sort-linked-list-already-sorted-using-absolute-values/README.md +++ b/problems/sort-linked-list-already-sorted-using-absolute-values/README.md @@ -9,7 +9,7 @@ [Next >](../number-of-valid-words-in-a-sentence "Number of Valid Words in a Sentence") -## [2046. Sort Linked List Already Sorted Using Absolute Values (Medium)](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values "") +## [2046. Sort Linked List Already Sorted Using Absolute Values (Medium)](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values "给按照绝对值排序的链表排序") diff --git a/problems/sort-transformed-array/README.md b/problems/sort-transformed-array/README.md index 5e0bdca3e..6135d7d68 100644 --- a/problems/sort-transformed-array/README.md +++ b/problems/sort-transformed-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../logger-rate-limiter "Logger Rate Limiter") diff --git a/problems/sorting-the-sentence/README.md b/problems/sorting-the-sentence/README.md index bf34188c7..8f696c17d 100644 --- a/problems/sorting-the-sentence/README.md +++ b/problems/sorting-the-sentence/README.md @@ -53,6 +53,9 @@ [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Check if Numbers Are Ascending in a Sentence](../check-if-numbers-are-ascending-in-a-sentence) (Easy) + ### HintsExample 4:
- --Input: nums = [3,6,7,7,0] -Output: -1 --
Constraints:
diff --git a/problems/special-positions-in-a-binary-matrix/README.md b/problems/special-positions-in-a-binary-matrix/README.md index a3e5ee837..3f8fe5cdd 100644 --- a/problems/special-positions-in-a-binary-matrix/README.md +++ b/problems/special-positions-in-a-binary-matrix/README.md @@ -11,60 +11,35 @@ ## [1582. Special Positions in a Binary Matrix (Easy)](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") -Given a rows x cols matrix mat, where mat[i][j] is either 0 or 1, return the number of special positions in mat.
Given an m x n binary matrix mat, return the number of special positions in mat.
A position (i,j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed).
A position (i, j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed).
Example 1:
- +
-Input: mat = [[1,0,0], - [0,0,1], - [1,0,0]] +Input: mat = [[1,0,0],[0,0,1],[1,0,0]] Output: 1 -Explanation: (1,2) is a special position because mat[1][2] == 1 and all other elements in row 1 and column 2 are 0. +Explanation: (1, 2) is a special position because mat[1][2] == 1 and all other elements in row 1 and column 2 are 0.
Example 2:
- --Input: mat = [[1,0,0], - [0,1,0], - [0,0,1]] -Output: 3 -Explanation: (0,0), (1,1) and (2,2) are special positions. -- -
Example 3:
- --Input: mat = [[0,0,0,1], - [1,0,0,0], - [0,1,1,0], - [0,0,0,0]] -Output: 2 -- -
Example 4:
- +
-Input: mat = [[0,0,0,0,0], - [1,0,0,0,0], - [0,1,0,0,0], - [0,0,1,0,0], - [0,0,0,1,1]] +Input: mat = [[1,0,0],[0,1,0],[0,0,1]] Output: 3 +Explanation: (0, 0), (1, 1) and (2, 2) are special positions.
Constraints:
rows == mat.lengthcols == mat[i].length1 <= rows, cols <= 100mat[i][j] is 0 or 1.m == mat.lengthn == mat[i].length1 <= m, n <= 100mat[i][j] is either 0 or 1.Example 1:
-Input: num = "123456579" -Output: [123,456,579] +Input: num = "1101111" +Output: [11,0,11,11] +Explanation: The output [110, 1, 111] would also be accepted.
Example 2:
--Input: num = "11235813" -Output: [1,1,2,3,5,8,13] -- -
Example 3:
-Input: num = "112358130" Output: [] Explanation: The task is impossible.-
Example 4:
+Example 3:
Input: num = "0123" @@ -56,14 +50,6 @@ Explanation: Leading zeroes are not allowed, so "01", "2", "3" is not valid.-
Example 5:
- --Input: num = "1101111" -Output: [11,0,11,11] -Explanation: The output [11, 0, 11, 11] would also be accepted. --
Constraints:
diff --git a/problems/split-array-with-same-average/README.md b/problems/split-array-with-same-average/README.md index 248dac471..f7cfa9d69 100644 --- a/problems/split-array-with-same-average/README.md +++ b/problems/split-array-with-same-average/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-morse-code-words "Unique Morse Code Words") diff --git a/problems/split-two-strings-to-make-palindrome/README.md b/problems/split-two-strings-to-make-palindrome/README.md index 8684258eb..b8a9ef7b2 100644 --- a/problems/split-two-strings-to-make-palindrome/README.md +++ b/problems/split-two-strings-to-make-palindrome/README.md @@ -34,8 +34,8 @@ Then, aprefix + bsuffix = "" + "y" = &Example 2:
-Input: a = "abdef", b = "fecab" -Output: true +Input: a = "xbdef", b = "xecab" +Output: false
Example 3:
@@ -49,13 +49,6 @@ bprefix = "jiz", bsuffix = "alu" Then, aprefix + bsuffix = "ula" + "alu" = "ulaalu", which is a palindrome. -Example 4:
- --Input: a = "xbdef", b = "xecab" -Output: false --
Constraints:
@@ -66,9 +59,9 @@ Then, aprefix + bsuffix = "ula" + "alu" ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### HintsExample 4:
- --Input: s = "10009998" -Output: true -Explanation: s can be split into ["100", "099", "98"] with numerical values [100,99,98]. -The values are in descending order with adjacent values differing by 1. --
Constraints:
diff --git a/problems/squares-of-a-sorted-array/README.md b/problems/squares-of-a-sorted-array/README.md index db487bee4..d4c8ef936 100644 --- a/problems/squares-of-a-sorted-array/README.md +++ b/problems/squares-of-a-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-perimeter-triangle "Largest Perimeter Triangle") diff --git a/problems/stamping-the-grid/README.md b/problems/stamping-the-grid/README.md new file mode 100644 index 000000000..e11e22239 --- /dev/null +++ b/problems/stamping-the-grid/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../longest-palindrome-by-concatenating-two-letter-words "Longest Palindrome by Concatenating Two Letter Words") + +[Next >](../check-if-every-row-and-column-contains-all-numbers "Check if Every Row and Column Contains All Numbers") + +## [2132. Stamping the Grid (Hard)](https://leetcode.com/problems/stamping-the-grid "用邮票贴满网格图") + +You are given an m x n binary matrix grid where each cell is either 0 (empty) or 1 (occupied).
You are then given stamps of size stampHeight x stampWidth. We want to fit the stamps such that they follow the given restrictions and requirements:
Return true if it is possible to fit the stamps while following the given restrictions and requirements. Otherwise, return false.
+
Example 1:
+
++Input: grid = [[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0]], stampHeight = 4, stampWidth = 3 +Output: true +Explanation: We have two overlapping stamps (labeled 1 and 2 in the image) that are able to cover all the empty cells. ++ +
Example 2:
+
++Input: grid = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]], stampHeight = 2, stampWidth = 2 +Output: false +Explanation: There is no way to fit the stamps onto all the empty cells without the stamps going outside the grid. ++ +
+
Constraints:
+ +m == grid.lengthn == grid[r].length1 <= m, n <= 1051 <= m * n <= 2 * 105grid[r][c] is either 0 or 1.1 <= stampHeight, stampWidth <= 105You are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue representing the value of the start node s, and a different integer destValue representing the value of the destination node t.
Find the shortest path starting from node s and ending at node t. Generate step-by-step directions of such path as a string consisting of only the uppercase letters 'L', 'R', and 'U'. Each letter indicates a specific direction:
'L' means to go from a node to its left child node.'R' means to go from a node to its right child node.'U' means to go from a node to its parent node.Return the step-by-step directions of the shortest path from node s to node t.
+
Example 1:
+
++Input: root = [5,1,2,3,null,6,4], startValue = 3, destValue = 6 +Output: "UURL" +Explanation: The shortest path is: 3 → 1 → 5 → 2 → 6. ++ +
Example 2:
+
++Input: root = [2,1], startValue = 2, destValue = 1 +Output: "L" +Explanation: The shortest path is: 2 → 1. ++ +
+
Constraints:
+ +n.2 <= n <= 1051 <= Node.val <= n1 <= startValue, destValue <= nstartValue != destValueAlice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.
Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.
Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2 or 3 stones from the first remaining stones in the row.
+Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2, or 3 stones from the first remaining stones in the row.
The score of each player is the sum of values of the stones taken. The score of each player is 0 initially.
+The score of each player is the sum of the values of the stones taken. The score of each player is 0 initially.
The objective of the game is to end with the highest score, and the winner is the player with the highest score and there could be a tie. The game continues until all the stones have been taken.
-Assume Alice and Bob play optimally.
+Assume Alice and Bob play optimally.
-Return "Alice" if Alice will win, "Bob" if Bob will win or "Tie" if they end the game with the same score.
+Return "Alice" if Alice will win, "Bob" if Bob will win, or "Tie" if they will end the game with the same score.
Example 1:
@@ -38,8 +38,8 @@ Input: values = [1,2,3,-9] Output: "Alice" Explanation: Alice must choose all the three piles at the first move to win and leave Bob with negative score. -If Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. The next move Alice will take the pile with value = -9 and lose. -If Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. The next move Alice will take the pile with value = -9 and also lose. +If Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. In the next move, Alice will take the pile with value = -9 and lose. +If Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. In the next move, Alice will take the pile with value = -9 and also lose. Remember that both play optimally so here Alice will choose the scenario that makes her win. @@ -51,26 +51,12 @@ Remember that both play optimally so here Alice will choose the scenario that ma Explanation: Alice cannot win this game. She can end the game in a draw if she decided to choose all the first three piles, otherwise she will lose. -Example 4:
- --Input: values = [1,2,3,-1,-2,-3,7] -Output: "Alice" -- -
Example 5:
- --Input: values = [-1,-2,-3] -Output: "Tie" --
Constraints:
1 <= values.length <= 50000-1000 <= values[i] <= 10001 <= stoneValue.length <= 5 * 104-1000 <= stoneValue[i] <= 1000Alice and Bob take turns playing a game, with Alice starting first.
-Initially, there are n stones in a pile. On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.
Initially, there are n stones in a pile. On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.
Also, if a player cannot make a move, he/she loses the game.
-Given a positive integer n. Return True if and only if Alice wins the game otherwise return False, assuming both players play optimally.
Given a positive integer n, return true if and only if Alice wins the game otherwise return false, assuming both players play optimally.
Example 1:
@@ -32,7 +32,8 @@Input: n = 2 Output: false -Explanation: Alice can only remove 1 stone, after that Bob removes the last one winning the game (2 -> 1 -> 0).+Explanation: Alice can only remove 1 stone, after that Bob removes the last one winning the game (2 -> 1 -> 0). +
Example 3:
@@ -42,28 +43,11 @@ Explanation: n is already a perfect square, Alice can win with one move, removing 4 stones (4 -> 0). -Example 4:
- --Input: n = 7 -Output: false -Explanation: Alice can't win the game if Bob plays optimally. -If Alice starts removing 4 stones, Bob will remove 1 stone then Alice should remove only 1 stone and finally Bob removes the last one (7 -> 3 -> 2 -> 1 -> 0). -If Alice starts removing 1 stone, Bob will remove 4 stones then Alice only can remove 1 stone and finally Bob removes the last one (7 -> 6 -> 2 -> 1 -> 0).- -
Example 5:
- --Input: n = 17 -Output: false -Explanation: Alice can't win the game if Bob plays optimally. --
Constraints:
1 <= n <= 10^51 <= n <= 105
Example 1:
- -
Input: targetGrid = [[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]] Output: true
Example 2:
- -
Input: targetGrid = [[1,1,1,1],[1,1,3,3],[1,1,3,4],[5,5,1,4]] Output: true @@ -46,13 +42,7 @@-Input: targetGrid = [[1,2,1],[2,1,2],[1,2,1]] Output: false -Explanation: It is impossible to form targetGrid because it is not allowed to print the same color in different turns.- -Example 4:
- --Input: targetGrid = [[1,1,1],[3,1,3]] -Output: false +Explanation: It is impossible to form targetGrid because it is not allowed to print the same color in different turns.diff --git a/problems/stream-of-characters/README.md b/problems/stream-of-characters/README.md index 1ed4f85dc..3f297045a 100644 --- a/problems/stream-of-characters/README.md +++ b/problems/stream-of-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-sum-of-two-non-overlapping-subarrays "Maximum Sum of Two Non-Overlapping Subarrays") @@ -60,10 +60,10 @@ streamChecker.query("l"); // return True, because 'kl' is in t ### Related Topics - [[Design](../../tag/design/README.md)] - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] [[Data Stream](../../tag/data-stream/README.md)] ### Hints diff --git a/problems/string-matching-in-an-array/README.md b/problems/string-matching-in-an-array/README.md index 39e81221c..0465ce113 100644 --- a/problems/string-matching-in-an-array/README.md +++ b/problems/string-matching-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../top-travellers "Top Travellers") diff --git a/problems/string-to-integer-atoi/README.md b/problems/string-to-integer-atoi/README.md index f3583d52e..fc45cb209 100644 --- a/problems/string-to-integer-atoi/README.md +++ b/problems/string-to-integer-atoi/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-integer "Reverse Integer") @@ -80,38 +80,6 @@ The parsed integer is 4193. Since 4193 is in the range [-231, 231 - 1], the final result is 4193.
Example 4:
- --Input: s = "words and 987" -Output: 0 -Explanation: -Step 1: "words and 987" (no characters read because there is no leading whitespace) - ^ -Step 2: "words and 987" (no characters read because there is neither a '-' nor '+') - ^ -Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w') - ^ -The parsed integer is 0 because no digits were read. -Since 0 is in the range [-231, 231 - 1], the final result is 0. -- -
Example 5:
- -
-Input: s = "-91283472332"
-Output: -2147483648
-Explanation:
-Step 1: "-91283472332" (no characters read because there is no leading whitespace)
- ^
-Step 2: "-91283472332" ('-' is read, so the result should be negative)
- ^
-Step 3: "-91283472332" ("91283472332" is read in)
- ^
-The parsed integer is -91283472332.
-Since -91283472332 is less than the lower bound of the range [-231, 231 - 1], the final result is clamped to -231 = -2147483648.
-
-
Constraints:
@@ -124,5 +92,6 @@ Since -91283472332 is less than the lower bound of the range [-231, 2 [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Reverse Integer](../reverse-integer) (Easy) + 1. [Reverse Integer](../reverse-integer) (Medium) 1. [Valid Number](../valid-number) (Hard) + 1. [Check if Numbers Are Ascending in a Sentence](../check-if-numbers-are-ascending-in-a-sentence) (Easy) diff --git a/problems/strings-differ-by-one-character/README.md b/problems/strings-differ-by-one-character/README.md index 16a62cb47..497638a14 100644 --- a/problems/strings-differ-by-one-character/README.md +++ b/problems/strings-differ-by-one-character/README.md @@ -16,8 +16,8 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### HintsExample 3:
- --Input: c = 4 -Output: true -- -
Example 4:
- --Input: c = 2 -Output: true -- -
Example 5:
- --Input: c = 1 -Output: true --
Constraints:
diff --git a/problems/sum-of-subarray-minimums/README.md b/problems/sum-of-subarray-minimums/README.md index bb47a9d74..ee1e208f7 100644 --- a/problems/sum-of-subarray-minimums/README.md +++ b/problems/sum-of-subarray-minimums/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../super-palindromes "Super Palindromes") diff --git a/problems/sum-of-subarray-ranges/README.md b/problems/sum-of-subarray-ranges/README.md new file mode 100644 index 000000000..78e5d4cbd --- /dev/null +++ b/problems/sum-of-subarray-ranges/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../rings-and-rods "Rings and Rods") + +[Next >](../watering-plants-ii "Watering Plants II") + +## [2104. Sum of Subarray Ranges (Medium)](https://leetcode.com/problems/sum-of-subarray-ranges "子数组范围和") + +You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray.
Return the sum of all subarray ranges of nums.
A subarray is a contiguous non-empty sequence of elements within an array.
+ ++
Example 1:
+ ++Input: nums = [1,2,3] +Output: 4 +Explanation: The 6 subarrays of nums are the following: +[1], range = largest - smallest = 1 - 1 = 0 +[2], range = 2 - 2 = 0 +[3], range = 3 - 3 = 0 +[1,2], range = 2 - 1 = 1 +[2,3], range = 3 - 2 = 1 +[1,2,3], range = 3 - 1 = 2 +So the sum of all ranges is 0 + 0 + 0 + 1 + 1 + 2 = 4.+ +
Example 2:
+ ++Input: nums = [1,3,3] +Output: 4 +Explanation: The 6 subarrays of nums are the following: +[1], range = largest - smallest = 1 - 1 = 0 +[3], range = 3 - 3 = 0 +[3], range = 3 - 3 = 0 +[1,3], range = 3 - 1 = 2 +[3,3], range = 3 - 3 = 0 +[1,3,3], range = 3 - 1 = 2 +So the sum of all ranges is 0 + 0 + 0 + 2 + 0 + 2 = 4. ++ +
Example 3:
+ ++Input: nums = [4,-2,-3,4,1] +Output: 59 +Explanation: The sum of all subarray ranges of nums is 59. ++ +
+
Constraints:
+ +1 <= nums.length <= 1000-109 <= nums[i] <= 109+
Follow-up: Could you find a solution with O(n) time complexity?
Example 1:
-
--Input: grid = [[2]] -Output: 10 -- -
Example 2:
Input: grid = [[1,2],[3,4]] Output: 34-
Example 3:
-
--Input: grid = [[1,0],[0,2]] -Output: 16 -- -
Example 4:
+Example 2:
Input: grid = [[1,1,1],[1,0,1],[1,1,1]] Output: 32-
Example 5:
+Example 3:
Input: grid = [[2,2,2],[2,1,2],[2,2,2]] @@ -59,8 +45,7 @@Constraints:
n == grid.lengthn == grid[i].lengthn == grid.length == grid[i].length1 <= n <= 500 <= grid[i][j] <= 50Example 3:
- --Input: start = "LLR", end = "RRL" -Output: false -- -
Example 4:
- --Input: start = "XL", end = "LX" -Output: true -- -
Example 5:
- --Input: start = "XLLR", end = "LXLX" -Output: false --
Constraints:
diff --git a/problems/swap-for-longest-repeated-character-substring/README.md b/problems/swap-for-longest-repeated-character-substring/README.md index 117c95cdd..d4f009b32 100644 --- a/problems/swap-for-longest-repeated-character-substring/README.md +++ b/problems/swap-for-longest-repeated-character-substring/README.md @@ -21,7 +21,7 @@Input: text = "ababa" Output: 3 -Explanation: We can swap the first 'b' with the last 'a', or the last 'b' with the first 'a'. Then, the longest repeated character substring is "aaa", which its length is 3. +Explanation: We can swap the first 'b' with the last 'a', or the last 'b' with the first 'a'. Then, the longest repeated character substring is "aaa" with length 3.
Example 2:
@@ -29,29 +29,15 @@Input: text = "aaabaaa" Output: 6 -Explanation: Swap 'b' with the last 'a' (or the first 'a'), and we get longest repeated character substring "aaaaaa", which its length is 6. +Explanation: Swap 'b' with the last 'a' (or the first 'a'), and we get longest repeated character substring "aaaaaa" with length 6.
Example 3:
--Input: text = "aaabbaaa" -Output: 4 -- -
Example 4:
-Input: text = "aaaaa" Output: 5 -Explanation: No need to swap, longest repeated character substring is "aaaaa", length is 5. -- -
Example 5:
- --Input: text = "abcdef" -Output: 1 +Explanation: No need to swap, longest repeated character substring is "aaaaa" with length is 5.
diff --git a/problems/swapping-nodes-in-a-linked-list/README.md b/problems/swapping-nodes-in-a-linked-list/README.md index 6ec21a3ad..230f24024 100644 --- a/problems/swapping-nodes-in-a-linked-list/README.md +++ b/problems/swapping-nodes-in-a-linked-list/README.md @@ -17,7 +17,7 @@
Example 1:
-
+
Input: head = [1,2,3,4,5], k = 2 Output: [1,4,3,2,5] @@ -30,27 +30,6 @@ Output: [7,9,6,6,8,7,3,0,9,5]-
Example 3:
- --Input: head = [1], k = 1 -Output: [1] -- -
Example 4:
- --Input: head = [1,2], k = 1 -Output: [2,1] -- -
Example 5:
- --Input: head = [1,2,3], k = 2 -Output: [1,2,3] --
Constraints:
@@ -64,6 +43,11 @@ [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] +### Similar Questions + 1. [Remove Nth Node From End of List](../remove-nth-node-from-end-of-list) (Medium) + 1. [Swap Nodes in Pairs](../swap-nodes-in-pairs) (Medium) + 1. [Reverse Nodes in k-Group](../reverse-nodes-in-k-group) (Hard) + ### HintsGiven an array of integers arr and an integer k.
Given an array of integers arr and an integer k.
A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the median of the array.
+
A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the median of the array.
If |arr[i] - m| == |arr[j] - m|, then arr[i] is said to be stronger than arr[j] if arr[i] > arr[j].
Return a list of the strongest k values in the array. return the answer in any arbitrary order.
Median is the middle value in an ordered integer list. More formally, if the length of the list is n, the median is the element in position ((n - 1) / 2) in the sorted list (0-indexed).
Median is the middle value in an ordered integer list. More formally, if the length of the list is n, the median is the element in position ((n - 1) / 2) in the sorted list (0-indexed).
arr = [6, -3, 7, 2, 11], n = 5 and the median is obtained by sorting the array arr = [-3, 2, 6, 7, 11] and the median is arr[m] where m = ((5 - 1) / 2) = 2. The median is 6.arr = [-7, 22, 17, 3], n = 4 and the median is obtained by sorting the array arr = [-7, 3, 17, 22] and the median is arr[m] where m = ((4 - 1) / 2) = 1. The median is 3.arr = [6, -3, 7, 2, 11], n = 5 and the median is obtained by sorting the array arr = [-3, 2, 6, 7, 11] and the median is arr[m] where m = ((5 - 1) / 2) = 2. The median is 6.arr = [-7, 22, 17, 3], n = 4 and the median is obtained by sorting the array arr = [-7, 3, 17, 22] and the median is arr[m] where m = ((4 - 1) / 2) = 1. The median is 3.@@ -52,26 +52,12 @@ Please note that although |5 - 3| == |1 - 3| but 5 is stronger than 1 because 5 Any permutation of [11,8,6,6,7] is accepted. -
Example 4:
- --Input: arr = [6,-3,7,2,11], k = 3 -Output: [-3,11,2] -- -
Example 5:
- --Input: arr = [-7,22,17,3], k = 2 -Output: [22,17] --
Constraints:
1 <= arr.length <= 10^5-10^5 <= arr[i] <= 10^51 <= arr.length <= 105-105 <= arr[i] <= 1051 <= k <= arr.lengthGiven two positive integers n and k.
You are given two positive integers n and k. A factor of an integer n is defined as an integer i where n % i == 0.
A factor of an integer n is defined as an integer i where n % i == 0.
Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factors.
Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factors.
Example 1:
@@ -23,7 +21,7 @@Input: n = 12, k = 3 Output: 3 -Explanation: Factors list is [1, 2, 3, 4, 6, 12], the 3rd factor is 3. +Explanation: Factors list is [1, 2, 3, 4, 6, 12], the 3rd factor is 3.
Example 2:
@@ -31,7 +29,7 @@Input: n = 7, k = 2 Output: 7 -Explanation: Factors list is [1, 7], the 2nd factor is 7. +Explanation: Factors list is [1, 7], the 2nd factor is 7.
Example 3:
@@ -42,22 +40,6 @@ Explanation: Factors list is [1, 2, 4], there is only 3 factors. We should return -1. -Example 4:
- --Input: n = 1, k = 1 -Output: 1 -Explanation: Factors list is [1], the 1st factor is 1. -- -
Example 5:
- --Input: n = 1000, k = 3 -Output: 4 -Explanation: Factors list is [1, 2, 4, 5, 8, 10, 20, 25, 40, 50, 100, 125, 200, 250, 500, 1000]. --
Constraints:
diff --git a/problems/the-most-frequently-ordered-products-for-each-customer/README.md b/problems/the-most-frequently-ordered-products-for-each-customer/README.md index 876cd2c83..e820d61c9 100644 --- a/problems/the-most-frequently-ordered-products-for-each-customer/README.md +++ b/problems/the-most-frequently-ordered-products-for-each-customer/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [The Most Recent Orders for Each Product](../the-most-recent-orders-for-each-product) (Medium) diff --git a/problems/the-number-of-full-rounds-you-have-played/README.md b/problems/the-number-of-full-rounds-you-have-played/README.md index 72715c1e9..79d5b74f0 100644 --- a/problems/the-number-of-full-rounds-you-have-played/README.md +++ b/problems/the-number-of-full-rounds-you-have-played/README.md @@ -11,54 +11,53 @@ ## [1904. The Number of Full Rounds You Have Played (Medium)](https://leetcode.com/problems/the-number-of-full-rounds-you-have-played "你完成的完整对局数") -A new online video game has been released, and in this video game, there are 15-minute rounds scheduled every quarter-hour period. This means that at HH:00, HH:15, HH:30 and HH:45, a new round starts, where HH represents an integer number from 00 to 23. A 24-hour clock is used, so the earliest time in the day is 00:00 and the latest is 23:59.
You are participating in an online chess tournament. There is a chess round that starts every 15 minutes. The first round of the day starts at 00:00, and after every 15 minutes, a new round starts.
Given two strings startTime and finishTime in the format "HH:MM" representing the exact time you started and finished playing the game, respectively, calculate the number of full rounds that you played during your game session.
00:15, the fourth round starts at 00:45, and the seventh round starts at 01:30.You are given two strings loginTime and logoutTime where:
startTime = "05:20" and finishTime = "05:59" this means you played only one full round from 05:30 to 05:45. You did not play the full round from 05:15 to 05:30 because you started after the round began, and you did not play the full round from 05:45 to 06:00 because you stopped before the round ended.loginTime is the time you will login to the game, andlogoutTime is the time you will logout from the game.If finishTime is earlier than startTime, this means you have played overnight (from startTime to the midnight and from midnight to finishTime).
If logoutTime is earlier than loginTime, this means you have played from loginTime to midnight and from midnight to logoutTime.
Return the number of full chess rounds you have played in the tournament.
-Return the number of full rounds that you have played if you had started playing at startTime and finished at finishTime.
Note: All the given times follow the 24-hour clock. That means the first round of the day starts at 00:00 and the last round of the day starts at 23:45.
Example 1:
-Input: startTime = "12:01", finishTime = "12:44" +Input: loginTime = "09:31", logoutTime = "10:14" Output: 1 -Explanation: You played one full round from 12:15 to 12:30. -You did not play the full round from 12:00 to 12:15 because you started playing at 12:01 after it began. -You did not play the full round from 12:30 to 12:45 because you stopped playing at 12:44 before it ended. +Explanation: You played one full round from 09:45 to 10:00. +You did not play the full round from 09:30 to 09:45 because you logged in at 09:31 after it began. +You did not play the full round from 10:00 to 10:15 because you logged out at 10:14 before it ended.
Example 2:
-Input: startTime = "20:00", finishTime = "06:00" -Output: 40 -Explanation: You played 16 full rounds from 20:00 to 00:00 and 24 full rounds from 00:00 to 06:00. -16 + 24 = 40. -- -
Example 3:
- --Input: startTime = "00:00", finishTime = "23:59" -Output: 95 -Explanation: You played 4 full rounds each hour except for the last hour where you played 3 full rounds. +Input: loginTime = "21:30", logoutTime = "03:00" +Output: 22 +Explanation: You played 10 full rounds from 21:30 to 00:00 and 12 full rounds from 00:00 to 03:00. +10 + 12 = 22.
Constraints:
startTime and finishTime are in the format HH:MM.00 <= HH <= 2300 <= MM <= 59startTime and finishTime are not equal.loginTime and logoutTime are in the format hh:mm.00 <= hh <= 2300 <= mm <= 59loginTime and logoutTime are not equal.Example 4:
- --Input: s = "1+2*3+4", answers = [13,21,11,15] -Output: 11 -Explanation: The correct answer of the expression is 11. -Every other student was rewarded 2 points because they could have applied the operators as follows: -- ((1+2)*3)+4 = 13 -- (1+2)*(3+4) = 21 -- 1+(2*(3+4)) = 15 -The points for the students are: [2,2,5,2]. The sum of the points is 11. --
Constraints:
diff --git a/problems/the-winner-university/README.md b/problems/the-winner-university/README.md index aa1d5cf91..569867b73 100644 --- a/problems/the-winner-university/README.md +++ b/problems/the-winner-university/README.md @@ -9,7 +9,7 @@ [Next >](../time-needed-to-buy-tickets "Time Needed to Buy Tickets") -## [2072. The Winner University (Easy)](https://leetcode.com/problems/the-winner-university "") +## [2072. The Winner University (Easy)](https://leetcode.com/problems/the-winner-university "赢得比赛的大学") diff --git a/problems/thousand-separator/README.md b/problems/thousand-separator/README.md index 66c20c984..87bf7dfd4 100644 --- a/problems/thousand-separator/README.md +++ b/problems/thousand-separator/README.md @@ -28,25 +28,11 @@ Output: "1.234" -Example 3:
- --Input: n = 123456789 -Output: "123.456.789" -- -
Example 4:
- --Input: n = 0 -Output: "0" --
Constraints:
0 <= n < 2310 <= n <= 231 - 1Example 3:
--Input: n = 7, headID = 6, manager = [1,2,3,4,5,6,-1], informTime = [0,6,5,4,3,2,1] -Output: 21 -Explanation: The head has id = 6. He will inform employee with id = 5 in 1 minute. -The employee with id = 5 will inform the employee with id = 4 in 2 minutes. -The employee with id = 4 will inform the employee with id = 3 in 3 minutes. -The employee with id = 3 will inform the employee with id = 2 in 4 minutes. -The employee with id = 2 will inform the employee with id = 1 in 5 minutes. -The employee with id = 1 will inform the employee with id = 0 in 6 minutes. -Needed time = 1 + 2 + 3 + 4 + 5 + 6 = 21. -- -
Example 4:
- --Input: n = 15, headID = 0, manager = [-1,0,0,1,1,2,2,3,3,4,4,5,5,6,6], informTime = [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0] -Output: 3 -Explanation: The first minute the head will inform employees 1 and 2. -The second minute they will inform employees 3, 4, 5 and 6. -The third minute they will inform the rest of employees. -- -
Example 5:
- --Input: n = 4, headID = 2, manager = [3,3,-1,2], informTime = [0,0,162,914] -Output: 1076 --
Constraints:
diff --git a/problems/total-sales-amount-by-year/README.md b/problems/total-sales-amount-by-year/README.md index 7a27cc853..f2a0dc254 100644 --- a/problems/total-sales-amount-by-year/README.md +++ b/problems/total-sales-amount-by-year/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-performance-of-a-team "Maximum Performance of a Team") diff --git a/problems/trapping-rain-water/README.md b/problems/trapping-rain-water/README.md index ea93f83c4..63809ff6f 100644 --- a/problems/trapping-rain-water/README.md +++ b/problems/trapping-rain-water/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../first-missing-positive "First Missing Positive") diff --git a/problems/tuple-with-same-product/README.md b/problems/tuple-with-same-product/README.md index 89f9e7bd6..bca35af2d 100644 --- a/problems/tuple-with-same-product/README.md +++ b/problems/tuple-with-same-product/README.md @@ -29,27 +29,13 @@Input: nums = [1,2,4,5,10] Output: 16 -Explanation: There are 16 valids tuples: +Explanation: There are 16 valid tuples: (1,10,2,5) , (1,10,5,2) , (10,1,2,5) , (10,1,5,2) (2,5,1,10) , (2,5,10,1) , (5,2,1,10) , (5,2,10,1) (2,10,4,5) , (2,10,5,4) , (10,2,4,5) , (10,2,5,4) (4,5,2,10) , (4,5,10,2) , (5,4,2,10) , (5,4,10,2)-
Example 3:
- --Input: nums = [2,3,4,6,8,12] -Output: 40 -- -
Example 4:
- --Input: nums = [2,3,5,7] -Output: 0 --
Constraints:
diff --git a/problems/two-sum/README.md b/problems/two-sum/README.md index 447a249c4..aa409a146 100644 --- a/problems/two-sum/README.md +++ b/problems/two-sum/README.md @@ -1,8 +1,8 @@ - - - + + + < Previous @@ -23,7 +23,7 @@Input: nums = [2,7,11,15], target = 9 Output: [0,1] -Output: Because nums[0] + nums[1] == 9, we return [0, 1]. +Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
Example 2:
@@ -60,7 +60,7 @@ ### Similar Questions 1. [3Sum](../3sum) (Medium) 1. [4Sum](../4sum) (Medium) - 1. [Two Sum II - Input array is sorted](../two-sum-ii-input-array-is-sorted) (Easy) + 1. [Two Sum II - Input Array Is Sorted](../two-sum-ii-input-array-is-sorted) (Medium) 1. [Two Sum III - Data structure design](../two-sum-iii-data-structure-design) (Easy) 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) 1. [Two Sum IV - Input is a BST](../two-sum-iv-input-is-a-bst) (Easy) diff --git a/problems/unique-substrings-with-equal-digit-frequency/README.md b/problems/unique-substrings-with-equal-digit-frequency/README.md new file mode 100644 index 000000000..18b80c84a --- /dev/null +++ b/problems/unique-substrings-with-equal-digit-frequency/README.md @@ -0,0 +1,47 @@ + + + + + + + +[< Previous](../minimum-time-to-remove-all-cars-containing-illegal-goods "Minimum Time to Remove All Cars Containing Illegal Goods") + +[Next >](../count-operations-to-obtain-zero "Count Operations to Obtain Zero") + +## [2168. Unique Substrings With Equal Digit Frequency (Medium)](https://leetcode.com/problems/unique-substrings-with-equal-digit-frequency "") + + + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] + +### Hints +You are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi]. An arrangement of pairs is valid if for every index i where 1 <= i < pairs.length, we have endi-1 == starti.
Return any valid arrangement of pairs.
Note: The inputs will be generated such that there exists a valid arrangement of pairs.
+
Example 1:
+ ++Input: pairs = [[5,1],[4,5],[11,9],[9,4]] +Output: [[11,9],[9,4],[4,5],[5,1]] +Explanation: +This is a valid arrangement since endi-1 always equals starti. +end0 = 9 == 9 = start1 +end1 = 4 == 4 = start2 +end2 = 5 == 5 = start3 ++ +
Example 2:
+ ++Input: pairs = [[1,3],[3,2],[2,1]] +Output: [[1,3],[3,2],[2,1]] +Explanation: +This is a valid arrangement since endi-1 always equals starti. +end0 = 3 == 3 = start1 +end1 = 2 == 2 = start2 +The arrangements [[2,1],[1,3],[3,2]] and [[3,2],[2,1],[1,3]] are also valid. ++ +
Example 3:
+ ++Input: pairs = [[1,2],[1,3],[2,1]] +Output: [[1,2],[2,1],[1,3]] +Explanation: +This is a valid arrangement since endi-1 always equals starti. +end0 = 2 == 2 = start1 +end1 = 1 == 1 = start2 ++ +
+
Constraints:
+ +1 <= pairs.length <= 105pairs[i].length == 20 <= starti, endi <= 109starti != endipairs.Given an equation, represented by words on left side and the result on right side.
Given an equation, represented by words on the left side and the result on the right side.
You need to check if the equation is solvable under the following rules:
+You need to check if the equation is solvable under the following rules:
words[i] and result are decoded as one number without leading zeros.words) will equal to the number on right side (result). words[i] and result are decoded as one number without leading zeros.words) will equal to the number on the right side (result).Return True if the equation is solvable otherwise return False.
Return true if the equation is solvable, otherwise return false.
Example 1:
@@ -43,13 +43,6 @@ Such that: "SIX" + "SEVEN" + "SEVEN" = "TWENTExample 3:
--Input: words = ["THIS","IS","TOO"], result = "FUNNY" -Output: true -- -
Example 4:
-Input: words = ["LEET","CODE"], result = "POINT" Output: false diff --git a/problems/video-stitching/README.md b/problems/video-stitching/README.md index c97194b4c..bc7031855 100644 --- a/problems/video-stitching/README.md +++ b/problems/video-stitching/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../camelcase-matching "Camelcase Matching") @@ -29,8 +29,7 @@+Hence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3. +Input: clips = [[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]], time = 10 Output: 3 -Explanation: -We take the clips [0,2], [8,10], [1,9]; a total of 3 clips. +Explanation: We take the clips [0,2], [8,10], [1,9]; a total of 3 clips. Then, we can reconstruct the sporting event as follows: We cut [1,9] into segments [1,2] + [2,8] + [8,9]. Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 10]. @@ -41,7 +40,7 @@ Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 1-Input: clips = [[0,1],[1,2]], time = 5 Output: -1 -Explanation: We can't cover [0,5] with only [0,1] and [1,2]. +Explanation: We cannot cover [0,5] with only [0,1] and [1,2].Example 3:
@@ -52,14 +51,6 @@ Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 1 Explanation: We can take clips [0,4], [4,7], and [6,9].Example 4:
- --Input: clips = [[0,4],[2,8]], time = 5 -Output: 2 -Explanation: Notice you can have extra video after the event ends. --
Constraints:
diff --git a/problems/vowels-of-all-substrings/README.md b/problems/vowels-of-all-substrings/README.md index 3d35932cd..a508e72c8 100644 --- a/problems/vowels-of-all-substrings/README.md +++ b/problems/vowels-of-all-substrings/README.md @@ -40,21 +40,15 @@ Hence, the total sum of vowels = 0 + 1 + 1 + 1 + 1 + 2 = 6. All possible substrings are: "a", "ab", "abc", "b", "bc", and "c". - "a", "ab", and "abc" have 1 vowel each - "b", "bc", and "c" have 0 vowels each -Hence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3.
Example 3:
Input: word = "ltcd" Output: 0 -Explanation: There are no vowels in any substring of "ltcd".- -
Example 4:
- --Input: word = "noosabasboosa" -Output: 237 -Explanation: There are a total of 237 vowels in all the substrings. +Explanation: There are no vowels in any substring of "ltcd".
diff --git a/problems/water-bottles/README.md b/problems/water-bottles/README.md index a12dce419..b299bdd88 100644 --- a/problems/water-bottles/README.md +++ b/problems/water-bottles/README.md @@ -11,55 +11,37 @@ ## [1518. Water Bottles (Easy)](https://leetcode.com/problems/water-bottles "换酒问题") -
Given numBottles full water bottles, you can exchange numExchange empty water bottles for one full water bottle.
There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle.
The operation of drinking a full water bottle turns it into an empty bottle.
-Return the maximum number of water bottles you can drink.
+Given the two integers numBottles and numExchange, return the maximum number of water bottles you can drink.
Example 1:
- -
Input: numBottles = 9, numExchange = 3 Output: 13 Explanation: You can exchange 3 empty bottles to get 1 full water bottle. -Number of water bottles you can drink: 9 + 3 + 1 = 13. +Number of water bottles you can drink: 9 + 3 + 1 = 13.
Example 2:
- -
Input: numBottles = 15, numExchange = 4 Output: 19 Explanation: You can exchange 4 empty bottles to get 1 full water bottle. -Number of water bottles you can drink: 15 + 3 + 1 = 19. -- -
Example 3:
- --Input: numBottles = 5, numExchange = 5 -Output: 6 -- -
Example 4:
- --Input: numBottles = 2, numExchange = 3 -Output: 2 +Number of water bottles you can drink: 15 + 3 + 1 = 19.
Constraints:
1 <= numBottles <= 1002 <= numExchange <= 1001 <= numBottles <= 1002 <= numExchange <= 100Alice and Bob want to water n plants in their garden. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i.
Each plant needs a specific amount of water. Alice and Bob have a watering can each, initially full. They water the plants in the following way:
+ +0th plant. Bob waters the plants in order from right to left, starting from the (n - 1)th plant. They begin watering the plants simultaneously.Given a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and two integers capacityA and capacityB representing the capacities of Alice's and Bob's watering cans respectively, return the number of times they have to refill to water all the plants.
+
Example 1:
+ ++Input: plants = [2,2,3,3], capacityA = 5, capacityB = 5 +Output: 1 +Explanation: +- Initially, Alice and Bob have 5 units of water each in their watering cans. +- Alice waters plant 0, Bob waters plant 3. +- Alice and Bob now have 3 units and 2 units of water respectively. +- Alice has enough water for plant 1, so she waters it. Bob does not have enough water for plant 2, so he refills his can then waters it. +So, the total number of times they have to refill to water all the plants is 0 + 0 + 1 + 0 = 1. ++ +
Example 2:
+ ++Input: plants = [2,2,3,3], capacityA = 3, capacityB = 4 +Output: 2 +Explanation: +- Initially, Alice and Bob have 3 units and 4 units of water in their watering cans respectively. +- Alice waters plant 0, Bob waters plant 3. +- Alice and Bob now have 1 unit of water each, and need to water plants 1 and 2 respectively. +- Since neither of them have enough water for their current plants, they refill their cans and then water the plants. +So, the total number of times they have to refill to water all the plants is 0 + 1 + 1 + 0 = 2. ++ +
Example 3:
+ ++Input: plants = [5], capacityA = 10, capacityB = 8 +Output: 0 +Explanation: +- There is only one plant. +- Alice's watering can has 10 units of water, whereas Bob's can has 8 units. Since Alice has more water in her can, she waters this plant. +So, the total number of times they have to refill is 0. ++ +
+
Constraints:
+ +n == plants.length1 <= n <= 1051 <= plants[i] <= 106max(plants[i]) <= capacityA, capacityB <= 109Follow up: Could you solve this in O(n) time?
Example 1:
-Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"] -Output: ["facebook","google","leetcode"] -
Example 2:
-Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"] -Output: ["apple","google","leetcode"] -
Example 3:
-Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","oo"] -Output: ["facebook","google"] -
Example 4:
-Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["lo","eo"] -Output: ["google","leetcode"] -
Example 5:
-Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["ec","oc","ceo"] -Output: ["facebook","leetcode"] + ++Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"] +Output: ["facebook","google","leetcode"]+ +Example 2:
+ ++Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"] +Output: ["apple","google","leetcode"] ++
Constraints:
diff --git a/problems/xor-operation-in-an-array/README.md b/problems/xor-operation-in-an-array/README.md index fb190c246..89580d8aa 100644 --- a/problems/xor-operation-in-an-array/README.md +++ b/problems/xor-operation-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../clone-binary-tree-with-random-pointer "Clone Binary Tree With Random Pointer") @@ -11,11 +11,11 @@ ## [1486. XOR Operation in an Array (Easy)](https://leetcode.com/problems/xor-operation-in-an-array "数组异或操作") -Given an integer
+nand an integerstart.You are given an integer
-nand an integerstart.Define an array
+numswherenums[i] = start + 2*i(0-indexed) andn == nums.length.Define an array
-numswherenums[i] = start + 2 * i(0-indexed) andn == nums.length.Return the bitwise XOR of all elements of
+nums.Return the bitwise XOR of all elements of
nums.
Example 1:
@@ -23,7 +23,7 @@Input: n = 5, start = 0 Output: 8 -Explanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8. +Explanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8. Where "^" corresponds to bitwise XOR operator.@@ -32,20 +32,7 @@ Where "^" corresponds to bitwise XOR operator.Input: n = 4, start = 3 Output: 8 -Explanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.- -Example 3:
- --Input: n = 1, start = 7 -Output: 7 -- -Example 4:
- --Input: n = 10, start = 5 -Output: 2 +Explanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.@@ -58,8 +45,8 @@ Where "^" corresponds to bitwise XOR operator. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
diff --git a/problems/xor-queries-of-a-subarray/README.md b/problems/xor-queries-of-a-subarray/README.md index 90df382e7..86c7462b0 100644 --- a/problems/xor-queries-of-a-subarray/README.md +++ b/problems/xor-queries-of-a-subarray/README.md @@ -54,8 +54,8 @@ The XOR values for queries are: ### Related Topics - [[Array](../../tag/array/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/readme/1-300.md b/readme/1-300.md index a4db89dcb..4bb184fe2 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions 50 | [Pow(x, n)](https://leetcode.com/problems/powx-n "Pow(x, n)") | [Go](../problems/powx-n) | Medium | | 51 | [N-Queens](https://leetcode.com/problems/n-queens "N 皇后") | [Go](../problems/n-queens) | Hard | | 52 | [N-Queens II](https://leetcode.com/problems/n-queens-ii "N皇后 II") | [Go](../problems/n-queens-ii) | Hard | -| 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray "最大子序和") | [Go](../problems/maximum-subarray) | Easy | +| 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray "最大子数组和") | [Go](../problems/maximum-subarray) | Easy | | 54 | [Spiral Matrix](https://leetcode.com/problems/spiral-matrix "螺旋矩阵") | [Go](../problems/spiral-matrix) | Medium | | 55 | [Jump Game](https://leetcode.com/problems/jump-game "跳跃游戏") | [Go](../problems/jump-game) | Medium | | 56 | [Merge Intervals](https://leetcode.com/problems/merge-intervals "合并区间") | [Go](../problems/merge-intervals) | Medium | @@ -146,7 +154,7 @@ LeetCode Problems' Solutions | 66 | [Plus One](https://leetcode.com/problems/plus-one "加一") | [Go](../problems/plus-one) | Easy | | 67 | [Add Binary](https://leetcode.com/problems/add-binary "二进制求和") | [Go](../problems/add-binary) | Easy | | 68 | [Text Justification](https://leetcode.com/problems/text-justification "文本左右对齐") | [Go](../problems/text-justification) | Hard | -| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx "Sqrt(x)") | [Go](../problems/sqrtx) | Easy | +| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx "x 的平方根 ") | [Go](../problems/sqrtx) | Easy | | 70 | [Climbing Stairs](https://leetcode.com/problems/climbing-stairs "爬楼梯") | [Go](../problems/climbing-stairs) | Easy | | 71 | [Simplify Path](https://leetcode.com/problems/simplify-path "简化路径") | [Go](../problems/simplify-path) | Medium | | 72 | [Edit Distance](https://leetcode.com/problems/edit-distance "编辑距离") | [Go](../problems/edit-distance) | Hard | @@ -223,7 +231,7 @@ LeetCode Problems' Solutions | 143 | [Reorder List](https://leetcode.com/problems/reorder-list "重排链表") | [Go](../problems/reorder-list) | Medium | | 144 | [Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历") | [Go](../problems/binary-tree-preorder-traversal) | Easy | | 145 | [Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") | [Go](../problems/binary-tree-postorder-traversal) | Easy | -| 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU 缓存机制") | [Go](../problems/lru-cache) | Medium | +| 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU 缓存") | [Go](../problems/lru-cache) | Medium | | 147 | [Insertion Sort List](https://leetcode.com/problems/insertion-sort-list "对链表进行插入排序") | [Go](../problems/insertion-sort-list) | Medium | | 148 | [Sort List](https://leetcode.com/problems/sort-list "排序链表") | [Go](../problems/sort-list) | Medium | | 149 | [Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line "直线上最多的点数") | [Go](../problems/max-points-on-a-line) | Hard | @@ -244,7 +252,7 @@ LeetCode Problems' Solutions | 164 | [Maximum Gap](https://leetcode.com/problems/maximum-gap "最大间距") | [Go](../problems/maximum-gap) | Hard | | 165 | [Compare Version Numbers](https://leetcode.com/problems/compare-version-numbers "比较版本号") | [Go](../problems/compare-version-numbers) | Medium | | 166 | [Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal "分数到小数") | [Go](../problems/fraction-to-recurring-decimal) | Medium | -| 167 | [Two Sum II - Input Array Is Sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") | [Go](../problems/two-sum-ii-input-array-is-sorted) | Easy | +| 167 | [Two Sum II - Input Array Is Sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") | [Go](../problems/two-sum-ii-input-array-is-sorted) | Medium | | 168 | [Excel Sheet Column Title](https://leetcode.com/problems/excel-sheet-column-title "Excel表列名称") | [Go](../problems/excel-sheet-column-title) | Easy | | 169 | [Majority Element](https://leetcode.com/problems/majority-element "多数元素") | [Go](../problems/majority-element) | Easy | | 170 | [Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii-data-structure-design "两数之和 III - 数据结构设计") 🔒 | [Go](../problems/two-sum-iii-data-structure-design) | Easy | @@ -361,7 +369,7 @@ LeetCode Problems' Solutions | 281 | [Zigzag Iterator](https://leetcode.com/problems/zigzag-iterator "锯齿迭代器") 🔒 | [Go](../problems/zigzag-iterator) | Medium | | 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 | +| 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 | | 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 | diff --git a/readme/1201-1500.md b/readme/1201-1500.md index 8b5c5123a..cd9ca1be8 100644 --- a/readme/1201-1500.md +++ b/readme/1201-1500.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions 1372 | [Longest ZigZag Path in a Binary Tree](https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree "二叉树中的最长交错路径") | [Go](../problems/longest-zigzag-path-in-a-binary-tree) | Medium | | 1373 | [Maximum Sum BST in Binary Tree](https://leetcode.com/problems/maximum-sum-bst-in-binary-tree "二叉搜索子树的最大键值和") | [Go](../problems/maximum-sum-bst-in-binary-tree) | Hard | | 1374 | [Generate a String With Characters That Have Odd Counts](https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts "生成每种字符都是奇数个的字符串") | [Go](../problems/generate-a-string-with-characters-that-have-odd-counts) | Easy | -| 1375 | [Bulb Switcher III](https://leetcode.com/problems/bulb-switcher-iii "灯泡开关 III") | [Go](../problems/bulb-switcher-iii) | Medium | +| 1375 | [Number of Times Binary String Is Prefix-Aligned](https://leetcode.com/problems/number-of-times-binary-string-is-prefix-aligned "二进制字符串前缀一致的次数") | [Go](../problems/number-of-times-binary-string-is-prefix-aligned) | Medium | | 1376 | [Time Needed to Inform All Employees](https://leetcode.com/problems/time-needed-to-inform-all-employees "通知所有员工所需的时间") | [Go](../problems/time-needed-to-inform-all-employees) | Medium | | 1377 | [Frog Position After T Seconds](https://leetcode.com/problems/frog-position-after-t-seconds "T 秒后青蛙的位置") | [Go](../problems/frog-position-after-t-seconds) | Hard | | 1378 | [Replace Employee ID With The Unique Identifier](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier "使用唯一标识码替换员工ID") 🔒 | [MySQL](../problems/replace-employee-id-with-the-unique-identifier) | Easy | diff --git a/readme/1501-1800.md b/readme/1501-1800.md new file mode 100644 index 000000000..85463f503 --- /dev/null +++ b/readme/1501-1800.md @@ -0,0 +1,388 @@ + + + + + + + +# [LeetCode](https://awesee.github.io/leetcode) +LeetCode Problems' Solutions +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] + +[](https://github.com/awesee/leetcode/actions) +[](https://codecov.io/gh/awesee/leetcode) +[](https://goreportcard.com/report/github.com/awesee/leetcode) +[](https://github.com/awesee/leetcode/graphs/contributors) +[](https://github.com/awesee/leetcode/blob/master/LICENSE) +[](https://app.fossa.io/projects/git%2Bgithub.com%2Fawesee%2Fleetcode?ref=badge_shield) +[](https://gitter.im/awesee/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + ++
+ +| # | Title | Solution | Difficulty | +| :-: | - | - | :-: | +| 1501 | [Countries You Can Safely Invest In](https://leetcode.com/problems/countries-you-can-safely-invest-in "可以放心投资的国家") 🔒 | [MySQL](../problems/countries-you-can-safely-invest-in) | Medium | +| 1502 | [Can Make Arithmetic Progression From Sequence](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") | [Go](../problems/can-make-arithmetic-progression-from-sequence) | Easy | +| 1503 | [Last Moment Before All Ants Fall Out of a Plank](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") | [Go](../problems/last-moment-before-all-ants-fall-out-of-a-plank) | Medium | +| 1504 | [Count Submatrices With All Ones](https://leetcode.com/problems/count-submatrices-with-all-ones "统计全 1 子矩形") | [Go](../problems/count-submatrices-with-all-ones) | Medium | +| 1505 | [Minimum Possible Integer After at Most K Adjacent Swaps On Digits](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") | [Go](../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | Hard | +| 1506 | [Find Root of N-Ary Tree](https://leetcode.com/problems/find-root-of-n-ary-tree "找到 N 叉树的根节点") 🔒 | [Go](../problems/find-root-of-n-ary-tree) | Medium | +| 1507 | [Reformat Date](https://leetcode.com/problems/reformat-date "转变日期格式") | [Go](../problems/reformat-date) | Easy | +| 1508 | [Range Sum of Sorted Subarray Sums](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums "子数组和排序后的区间和") | [Go](../problems/range-sum-of-sorted-subarray-sums) | Medium | +| 1509 | [Minimum Difference Between Largest and Smallest Value in Three Moves](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") | [Go](../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | Medium | +| 1510 | [Stone Game IV](https://leetcode.com/problems/stone-game-iv "石子游戏 IV") | [Go](../problems/stone-game-iv) | Hard | +| 1511 | [Customer Order Frequency](https://leetcode.com/problems/customer-order-frequency "消费者下单频率") 🔒 | [MySQL](../problems/customer-order-frequency) | Easy | +| 1512 | [Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs "好数对的数目") | [Go](../problems/number-of-good-pairs) | Easy | +| 1513 | [Number of Substrings With Only 1s](https://leetcode.com/problems/number-of-substrings-with-only-1s "仅含 1 的子串数") | [Go](../problems/number-of-substrings-with-only-1s) | Medium | +| 1514 | [Path with Maximum Probability](https://leetcode.com/problems/path-with-maximum-probability "概率最大的路径") | [Go](../problems/path-with-maximum-probability) | Medium | +| 1515 | [Best Position for a Service Centre](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") | [Go](../problems/best-position-for-a-service-centre) | Hard | +| 1516 | [Move Sub-Tree of N-Ary Tree](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree "移动 N 叉树的子树") 🔒 | [Go](../problems/move-sub-tree-of-n-ary-tree) | Hard | +| 1517 | [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails "查找拥有有效邮箱的用户") 🔒 | [MySQL](../problems/find-users-with-valid-e-mails) | Easy | +| 1518 | [Water Bottles](https://leetcode.com/problems/water-bottles "换酒问题") | [Go](../problems/water-bottles) | Easy | +| 1519 | [Number of Nodes in the Sub-Tree With the Same Label](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") | [Go](../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | Medium | +| 1520 | [Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") | [Go](../problems/maximum-number-of-non-overlapping-substrings) | Hard | +| 1521 | [Find a Value of a Mysterious Function Closest to Target](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target "找到最接近目标值的函数值") | [Go](../problems/find-a-value-of-a-mysterious-function-closest-to-target) | Hard | +| 1522 | [Diameter of N-Ary Tree](https://leetcode.com/problems/diameter-of-n-ary-tree "N 叉树的直径") 🔒 | [Go](../problems/diameter-of-n-ary-tree) | Medium | +| 1523 | [Count Odd Numbers in an Interval Range](https://leetcode.com/problems/count-odd-numbers-in-an-interval-range "在区间范围内统计奇数数目") | [Go](../problems/count-odd-numbers-in-an-interval-range) | Easy | +| 1524 | [Number of Sub-arrays With Odd Sum](https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum "和为奇数的子数组数目") | [Go](../problems/number-of-sub-arrays-with-odd-sum) | Medium | +| 1525 | [Number of Good Ways to Split a String](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") | [Go](../problems/number-of-good-ways-to-split-a-string) | Medium | +| 1526 | [Minimum Number of Increments on Subarrays to Form a Target Array](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") | [Go](../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | Hard | +| 1527 | [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition "患某种疾病的患者") 🔒 | [MySQL](../problems/patients-with-a-condition) | Easy | +| 1528 | [Shuffle String](https://leetcode.com/problems/shuffle-string "重新排列字符串") | [Go](../problems/shuffle-string) | Easy | +| 1529 | [Minimum Suffix Flips](https://leetcode.com/problems/minimum-suffix-flips "最少的后缀翻转次数") | [Go](../problems/minimum-suffix-flips) | Medium | +| 1530 | [Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") | [Go](../problems/number-of-good-leaf-nodes-pairs) | Medium | +| 1531 | [String Compression II](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") | [Go](../problems/string-compression-ii) | Hard | +| 1532 | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders "最近的三笔订单") 🔒 | [MySQL](../problems/the-most-recent-three-orders) | Medium | +| 1533 | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer "找到最大整数的索引") 🔒 | [Go](../problems/find-the-index-of-the-large-integer) | Medium | +| 1534 | [Count Good Triplets](https://leetcode.com/problems/count-good-triplets "统计好三元组") | [Go](../problems/count-good-triplets) | Easy | +| 1535 | [Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") | [Go](../problems/find-the-winner-of-an-array-game) | Medium | +| 1536 | [Minimum Swaps to Arrange a Binary Grid](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") | [Go](../problems/minimum-swaps-to-arrange-a-binary-grid) | Medium | +| 1537 | [Get the Maximum Score](https://leetcode.com/problems/get-the-maximum-score "最大得分") | [Go](../problems/get-the-maximum-score) | Hard | +| 1538 | [Guess the Majority in a Hidden Array](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array "找出隐藏数组中出现次数最多的元素") 🔒 | [Go](../problems/guess-the-majority-in-a-hidden-array) | Medium | +| 1539 | [Kth Missing Positive Number](https://leetcode.com/problems/kth-missing-positive-number "第 k 个缺失的正整数") | [Go](../problems/kth-missing-positive-number) | Easy | +| 1540 | [Can Convert String in K Moves](https://leetcode.com/problems/can-convert-string-in-k-moves "K 次操作转变字符串") | [Go](../problems/can-convert-string-in-k-moves) | Medium | +| 1541 | [Minimum Insertions to Balance a Parentheses String](https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string "平衡括号字符串的最少插入次数") | [Go](../problems/minimum-insertions-to-balance-a-parentheses-string) | Medium | +| 1542 | [Find Longest Awesome Substring](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") | [Go](../problems/find-longest-awesome-substring) | Hard | +| 1543 | [Fix Product Name Format](https://leetcode.com/problems/fix-product-name-format "产品名称格式修复") 🔒 | [MySQL](../problems/fix-product-name-format) | Easy | +| 1544 | [Make The String Great](https://leetcode.com/problems/make-the-string-great "整理字符串") | [Go](../problems/make-the-string-great) | Easy | +| 1545 | [Find Kth Bit in Nth Binary String](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") | [Go](../problems/find-kth-bit-in-nth-binary-string) | Medium | +| 1546 | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值且不重叠的非空子数组的最大数目") | [Go](../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium | +| 1547 | [Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") | [Go](../problems/minimum-cost-to-cut-a-stick) | Hard | +| 1548 | [The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph "图中最相似的路径") 🔒 | [Go](../problems/the-most-similar-path-in-a-graph) | Hard | +| 1549 | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product "每件商品的最新订单") 🔒 | [MySQL](../problems/the-most-recent-orders-for-each-product) | Medium | +| 1550 | [Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds "存在连续三个奇数的数组") | [Go](../problems/three-consecutive-odds) | Easy | +| 1551 | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](../problems/minimum-operations-to-make-array-equal) | Medium | +| 1552 | [Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") | [Go](../problems/magnetic-force-between-two-balls) | Medium | +| 1553 | [Minimum Number of Days to Eat N Oranges](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges "吃掉 N 个橘子的最少天数") | [Go](../problems/minimum-number-of-days-to-eat-n-oranges) | Hard | +| 1554 | [Strings Differ by One Character](https://leetcode.com/problems/strings-differ-by-one-character "只有一个不同字符的字符串") 🔒 | [Go](../problems/strings-differ-by-one-character) | Medium | +| 1555 | [Bank Account Summary](https://leetcode.com/problems/bank-account-summary "银行账户概要") 🔒 | [MySQL](../problems/bank-account-summary) | Medium | +| 1556 | [Thousand Separator](https://leetcode.com/problems/thousand-separator "千位分隔数") | [Go](../problems/thousand-separator) | Easy | +| 1557 | [Minimum Number of Vertices to Reach All Nodes](https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes "可以到达所有点的最少点数目") | [Go](../problems/minimum-number-of-vertices-to-reach-all-nodes) | Medium | +| 1558 | [Minimum Numbers of Function Calls to Make Target Array](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") | [Go](../problems/minimum-numbers-of-function-calls-to-make-target-array) | Medium | +| 1559 | [Detect Cycles in 2D Grid](https://leetcode.com/problems/detect-cycles-in-2d-grid "二维网格图中探测环") | [Go](../problems/detect-cycles-in-2d-grid) | Medium | +| 1560 | [Most Visited Sector in a Circular Track](https://leetcode.com/problems/most-visited-sector-in-a-circular-track "圆形赛道上经过次数最多的扇区") | [Go](../problems/most-visited-sector-in-a-circular-track) | Easy | +| 1561 | [Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") | [Go](../problems/maximum-number-of-coins-you-can-get) | Medium | +| 1562 | [Find Latest Group of Size M](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") | [Go](../problems/find-latest-group-of-size-m) | Medium | +| 1563 | [Stone Game V](https://leetcode.com/problems/stone-game-v "石子游戏 V") | [Go](../problems/stone-game-v) | Hard | +| 1564 | [Put Boxes Into the Warehouse I](https://leetcode.com/problems/put-boxes-into-the-warehouse-i "把箱子放进仓库里 I") 🔒 | [Go](../problems/put-boxes-into-the-warehouse-i) | Medium | +| 1565 | [Unique Orders and Customers Per Month](https://leetcode.com/problems/unique-orders-and-customers-per-month "按月统计订单数与顾客数") 🔒 | [MySQL](../problems/unique-orders-and-customers-per-month) | Easy | +| 1566 | [Detect Pattern of Length M Repeated K or More Times](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") | [Go](../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | Easy | +| 1567 | [Maximum Length of Subarray With Positive Product](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") | [Go](../problems/maximum-length-of-subarray-with-positive-product) | Medium | +| 1568 | [Minimum Number of Days to Disconnect Island](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") | [Go](../problems/minimum-number-of-days-to-disconnect-island) | Hard | +| 1569 | [Number of Ways to Reorder Array to Get Same BST](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") | [Go](../problems/number-of-ways-to-reorder-array-to-get-same-bst) | Hard | +| 1570 | [Dot Product of Two Sparse Vectors](https://leetcode.com/problems/dot-product-of-two-sparse-vectors "两个稀疏向量的点积") 🔒 | [Go](../problems/dot-product-of-two-sparse-vectors) | Medium | +| 1571 | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager "仓库经理") 🔒 | [MySQL](../problems/warehouse-manager) | Easy | +| 1572 | [Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum "矩阵对角线元素的和") | [Go](../problems/matrix-diagonal-sum) | Easy | +| 1573 | [Number of Ways to Split a String](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") | [Go](../problems/number-of-ways-to-split-a-string) | Medium | +| 1574 | [Shortest Subarray to be Removed to Make Array Sorted](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted "删除最短的子数组使剩余数组有序") | [Go](../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | Medium | +| 1575 | [Count All Possible Routes](https://leetcode.com/problems/count-all-possible-routes "统计所有可行路径") | [Go](../problems/count-all-possible-routes) | Hard | +| 1576 | [Replace All ?'s to Avoid Consecutive Repeating Characters](https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters "替换所有的问号") | [Go](../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | Easy | +| 1577 | [Number of Ways Where Square of Number Is Equal to Product of Two Numbers](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") | [Go](../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | Medium | +| 1578 | [Minimum Time to Make Rope Colorful](https://leetcode.com/problems/minimum-time-to-make-rope-colorful "使绳子变成彩色的最短时间") | [Go](../problems/minimum-time-to-make-rope-colorful) | Medium | +| 1579 | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") | [Go](../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard | +| 1580 | [Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii "把箱子放进仓库里 II") 🔒 | [Go](../problems/put-boxes-into-the-warehouse-ii) | Medium | +| 1581 | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的顾客") 🔒 | [MySQL](../problems/customer-who-visited-but-did-not-make-any-transactions) | Easy | +| 1582 | [Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") | [Go](../problems/special-positions-in-a-binary-matrix) | Easy | +| 1583 | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](../problems/count-unhappy-friends) | Medium | +| 1584 | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](../problems/min-cost-to-connect-all-points) | Medium | +| 1585 | [Check If String Is Transformable With Substring Sort Operations](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") | [Go](../problems/check-if-string-is-transformable-with-substring-sort-operations) | Hard | +| 1586 | [Binary Search Tree Iterator II](https://leetcode.com/problems/binary-search-tree-iterator-ii "二叉搜索树迭代器 II") 🔒 | [Go](../problems/binary-search-tree-iterator-ii) | Medium | +| 1587 | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii "银行账户概要 II") 🔒 | [MySQL](../problems/bank-account-summary-ii) | Easy | +| 1588 | [Sum of All Odd Length Subarrays](https://leetcode.com/problems/sum-of-all-odd-length-subarrays "所有奇数长度子数组的和") | [Go](../problems/sum-of-all-odd-length-subarrays) | Easy | +| 1589 | [Maximum Sum Obtained of Any Permutation](https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation "所有排列中的最大和") | [Go](../problems/maximum-sum-obtained-of-any-permutation) | Medium | +| 1590 | [Make Sum Divisible by P](https://leetcode.com/problems/make-sum-divisible-by-p "使数组和能被 P 整除") | [Go](../problems/make-sum-divisible-by-p) | Medium | +| 1591 | [Strange Printer II](https://leetcode.com/problems/strange-printer-ii "奇怪的打印机 II") | [Go](../problems/strange-printer-ii) | Hard | +| 1592 | [Rearrange Spaces Between Words](https://leetcode.com/problems/rearrange-spaces-between-words "重新排列单词间的空格") | [Go](../problems/rearrange-spaces-between-words) | Easy | +| 1593 | [Split a String Into the Max Number of Unique Substrings](https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings "拆分字符串使唯一子字符串的数目最大") | [Go](../problems/split-a-string-into-the-max-number-of-unique-substrings) | Medium | +| 1594 | [Maximum Non Negative Product in a Matrix](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") | [Go](../problems/maximum-non-negative-product-in-a-matrix) | Medium | +| 1595 | [Minimum Cost to Connect Two Groups of Points](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") | [Go](../problems/minimum-cost-to-connect-two-groups-of-points) | Hard | +| 1596 | [The Most Frequently Ordered Products for Each Customer](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer "每位顾客最经常订购的商品") 🔒 | [MySQL](../problems/the-most-frequently-ordered-products-for-each-customer) | Medium | +| 1597 | [Build Binary Expression Tree From Infix Expression](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression "根据中缀表达式构造二叉表达式树") 🔒 | [Go](../problems/build-binary-expression-tree-from-infix-expression) | Hard | +| 1598 | [Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder "文件夹操作日志搜集器") | [Go](../problems/crawler-log-folder) | Easy | +| 1599 | [Maximum Profit of Operating a Centennial Wheel](https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel "经营摩天轮的最大利润") | [Go](../problems/maximum-profit-of-operating-a-centennial-wheel) | Medium | +| 1600 | [Throne Inheritance](https://leetcode.com/problems/throne-inheritance "皇位继承顺序") | [Go](../problems/throne-inheritance) | Medium | +| 1601 | [Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests "最多可达成的换楼请求数目") | [Go](../problems/maximum-number-of-achievable-transfer-requests) | Hard | +| 1602 | [Find Nearest Right Node in Binary Tree](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree "找到二叉树中最近的右侧节点") 🔒 | [Go](../problems/find-nearest-right-node-in-binary-tree) | Medium | +| 1603 | [Design Parking System](https://leetcode.com/problems/design-parking-system "设计停车系统") | [Go](../problems/design-parking-system) | Easy | +| 1604 | [Alert Using Same Key-Card Three or More Times in a One Hour Period](https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "警告一小时内使用相同员工卡大于等于三次的人") | [Go](../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | Medium | +| 1605 | [Find Valid Matrix Given Row and Column Sums](https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums "给定行和列的和求可行矩阵") | [Go](../problems/find-valid-matrix-given-row-and-column-sums) | Medium | +| 1606 | [Find Servers That Handled Most Number of Requests](https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests "找到处理最多请求的服务器") | [Go](../problems/find-servers-that-handled-most-number-of-requests) | Hard | +| 1607 | [Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales "没有卖出的卖家") 🔒 | [MySQL](../problems/sellers-with-no-sales) | Easy | +| 1608 | [Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x "特殊数组的特征值") | [Go](../problems/special-array-with-x-elements-greater-than-or-equal-x) | Easy | +| 1609 | [Even Odd Tree](https://leetcode.com/problems/even-odd-tree "奇偶树") | [Go](../problems/even-odd-tree) | Medium | +| 1610 | [Maximum Number of Visible Points](https://leetcode.com/problems/maximum-number-of-visible-points "可见点的最大数目") | [Go](../problems/maximum-number-of-visible-points) | Hard | +| 1611 | [Minimum One Bit Operations to Make Integers Zero](https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero "使整数变为 0 的最少操作次数") | [Go](../problems/minimum-one-bit-operations-to-make-integers-zero) | Hard | +| 1612 | [Check If Two Expression Trees are Equivalent](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent "检查两棵二叉表达式树是否等价") 🔒 | [Go](../problems/check-if-two-expression-trees-are-equivalent) | Medium | +| 1613 | [Find the Missing IDs](https://leetcode.com/problems/find-the-missing-ids "找到遗失的ID") 🔒 | [MySQL](../problems/find-the-missing-ids) | Medium | +| 1614 | [Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses "括号的最大嵌套深度") | [Go](../problems/maximum-nesting-depth-of-the-parentheses) | Easy | +| 1615 | [Maximal Network Rank](https://leetcode.com/problems/maximal-network-rank "最大网络秩") | [Go](../problems/maximal-network-rank) | Medium | +| 1616 | [Split Two Strings to Make Palindrome](https://leetcode.com/problems/split-two-strings-to-make-palindrome "分割两个字符串得到回文串") | [Go](../problems/split-two-strings-to-make-palindrome) | Medium | +| 1617 | [Count Subtrees With Max Distance Between Cities](https://leetcode.com/problems/count-subtrees-with-max-distance-between-cities "统计子树中城市之间最大距离") | [Go](../problems/count-subtrees-with-max-distance-between-cities) | Hard | +| 1618 | [Maximum Font to Fit a Sentence in a Screen](https://leetcode.com/problems/maximum-font-to-fit-a-sentence-in-a-screen "找出适应屏幕的最大字号") 🔒 | [Go](../problems/maximum-font-to-fit-a-sentence-in-a-screen) | Medium | +| 1619 | [Mean of Array After Removing Some Elements](https://leetcode.com/problems/mean-of-array-after-removing-some-elements "删除某些元素后的数组均值") | [Go](../problems/mean-of-array-after-removing-some-elements) | Easy | +| 1620 | [Coordinate With Maximum Network Quality](https://leetcode.com/problems/coordinate-with-maximum-network-quality "网络信号最好的坐标") | [Go](../problems/coordinate-with-maximum-network-quality) | Medium | +| 1621 | [Number of Sets of K Non-Overlapping Line Segments](https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments "大小为 K 的不重叠线段的数目") | [Go](../problems/number-of-sets-of-k-non-overlapping-line-segments) | Medium | +| 1622 | [Fancy Sequence](https://leetcode.com/problems/fancy-sequence "奇妙序列") | [Go](../problems/fancy-sequence) | Hard | +| 1623 | [All Valid Triplets That Can Represent a Country](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country "三人国家代表队") 🔒 | [MySQL](../problems/all-valid-triplets-that-can-represent-a-country) | Easy | +| 1624 | [Largest Substring Between Two Equal Characters](https://leetcode.com/problems/largest-substring-between-two-equal-characters "两个相同字符之间的最长子字符串") | [Go](../problems/largest-substring-between-two-equal-characters) | Easy | +| 1625 | [Lexicographically Smallest String After Applying Operations](https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations "执行操作后字典序最小的字符串") | [Go](../problems/lexicographically-smallest-string-after-applying-operations) | Medium | +| 1626 | [Best Team With No Conflicts](https://leetcode.com/problems/best-team-with-no-conflicts "无矛盾的最佳球队") | [Go](../problems/best-team-with-no-conflicts) | Medium | +| 1627 | [Graph Connectivity With Threshold](https://leetcode.com/problems/graph-connectivity-with-threshold "带阈值的图连通性") | [Go](../problems/graph-connectivity-with-threshold) | Hard | +| 1628 | [Design an Expression Tree With Evaluate Function](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function "设计带解析函数的表达式树") 🔒 | [Go](../problems/design-an-expression-tree-with-evaluate-function) | Medium | +| 1629 | [Slowest Key](https://leetcode.com/problems/slowest-key "按键持续时间最长的键") | [Go](../problems/slowest-key) | Easy | +| 1630 | [Arithmetic Subarrays](https://leetcode.com/problems/arithmetic-subarrays "等差子数组") | [Go](../problems/arithmetic-subarrays) | Medium | +| 1631 | [Path With Minimum Effort](https://leetcode.com/problems/path-with-minimum-effort "最小体力消耗路径") | [Go](../problems/path-with-minimum-effort) | Medium | +| 1632 | [Rank Transform of a Matrix](https://leetcode.com/problems/rank-transform-of-a-matrix "矩阵转换后的秩") | [Go](../problems/rank-transform-of-a-matrix) | Hard | +| 1633 | [Percentage of Users Attended a Contest](https://leetcode.com/problems/percentage-of-users-attended-a-contest "各赛事的用户注册率") 🔒 | [MySQL](../problems/percentage-of-users-attended-a-contest) | Easy | +| 1634 | [Add Two Polynomials Represented as Linked Lists](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists "求两个多项式链表的和") 🔒 | [Go](../problems/add-two-polynomials-represented-as-linked-lists) | Medium | +| 1635 | [Hopper Company Queries I](https://leetcode.com/problems/hopper-company-queries-i "Hopper 公司查询 I") 🔒 | [MySQL](../problems/hopper-company-queries-i) | Hard | +| 1636 | [Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency "按照频率将数组升序排序") | [Go](../problems/sort-array-by-increasing-frequency) | Easy | +| 1637 | [Widest Vertical Area Between Two Points Containing No Points](https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points "两点之间不包含任何点的最宽垂直面积") | [Go](../problems/widest-vertical-area-between-two-points-containing-no-points) | Medium | +| 1638 | [Count Substrings That Differ by One Character](https://leetcode.com/problems/count-substrings-that-differ-by-one-character "统计只差一个字符的子串数目") | [Go](../problems/count-substrings-that-differ-by-one-character) | Medium | +| 1639 | [Number of Ways to Form a Target String Given a Dictionary](https://leetcode.com/problems/number-of-ways-to-form-a-target-string-given-a-dictionary "通过给定词典构造目标字符串的方案数") | [Go](../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | Hard | +| 1640 | [Check Array Formation Through Concatenation](https://leetcode.com/problems/check-array-formation-through-concatenation "能否连接形成数组") | [Go](../problems/check-array-formation-through-concatenation) | Easy | +| 1641 | [Count Sorted Vowel Strings](https://leetcode.com/problems/count-sorted-vowel-strings "统计字典序元音字符串的数目") | [Go](../problems/count-sorted-vowel-strings) | Medium | +| 1642 | [Furthest Building You Can Reach](https://leetcode.com/problems/furthest-building-you-can-reach "可以到达的最远建筑") | [Go](../problems/furthest-building-you-can-reach) | Medium | +| 1643 | [Kth Smallest Instructions](https://leetcode.com/problems/kth-smallest-instructions "第 K 条最小指令") | [Go](../problems/kth-smallest-instructions) | Hard | +| 1644 | [Lowest Common Ancestor of a Binary Tree II](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii "二叉树的最近公共祖先 II") 🔒 | [Go](../problems/lowest-common-ancestor-of-a-binary-tree-ii) | Medium | +| 1645 | [Hopper Company Queries II](https://leetcode.com/problems/hopper-company-queries-ii) 🔒 | [MySQL](../problems/hopper-company-queries-ii) | Hard | +| 1646 | [Get Maximum in Generated Array](https://leetcode.com/problems/get-maximum-in-generated-array "获取生成数组中的最大值") | [Go](../problems/get-maximum-in-generated-array) | Easy | +| 1647 | [Minimum Deletions to Make Character Frequencies Unique](https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique "字符频次唯一的最小删除次数") | [Go](../problems/minimum-deletions-to-make-character-frequencies-unique) | Medium | +| 1648 | [Sell Diminishing-Valued Colored Balls](https://leetcode.com/problems/sell-diminishing-valued-colored-balls "销售价值减少的颜色球") | [Go](../problems/sell-diminishing-valued-colored-balls) | Medium | +| 1649 | [Create Sorted Array through Instructions](https://leetcode.com/problems/create-sorted-array-through-instructions "通过指令创建有序数组") | [Go](../problems/create-sorted-array-through-instructions) | Hard | +| 1650 | [Lowest Common Ancestor of a Binary Tree III](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii "二叉树的最近公共祖先 III") 🔒 | [Go](../problems/lowest-common-ancestor-of-a-binary-tree-iii) | Medium | +| 1651 | [Hopper Company Queries III](https://leetcode.com/problems/hopper-company-queries-iii) 🔒 | [MySQL](../problems/hopper-company-queries-iii) | Hard | +| 1652 | [Defuse the Bomb](https://leetcode.com/problems/defuse-the-bomb "拆炸弹") | [Go](../problems/defuse-the-bomb) | Easy | +| 1653 | [Minimum Deletions to Make String Balanced](https://leetcode.com/problems/minimum-deletions-to-make-string-balanced "使字符串平衡的最少删除次数") | [Go](../problems/minimum-deletions-to-make-string-balanced) | Medium | +| 1654 | [Minimum Jumps to Reach Home](https://leetcode.com/problems/minimum-jumps-to-reach-home "到家的最少跳跃次数") | [Go](../problems/minimum-jumps-to-reach-home) | Medium | +| 1655 | [Distribute Repeating Integers](https://leetcode.com/problems/distribute-repeating-integers "分配重复整数") | [Go](../problems/distribute-repeating-integers) | Hard | +| 1656 | [Design an Ordered Stream](https://leetcode.com/problems/design-an-ordered-stream "设计有序流") | [Go](../problems/design-an-ordered-stream) | Easy | +| 1657 | [Determine if Two Strings Are Close](https://leetcode.com/problems/determine-if-two-strings-are-close "确定两个字符串是否接近") | [Go](../problems/determine-if-two-strings-are-close) | Medium | +| 1658 | [Minimum Operations to Reduce X to Zero](https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero "将 x 减到 0 的最小操作数") | [Go](../problems/minimum-operations-to-reduce-x-to-zero) | Medium | +| 1659 | [Maximize Grid Happiness](https://leetcode.com/problems/maximize-grid-happiness "最大化网格幸福感") | [Go](../problems/maximize-grid-happiness) | Hard | +| 1660 | [Correct a Binary Tree](https://leetcode.com/problems/correct-a-binary-tree "纠正二叉树") 🔒 | [Go](../problems/correct-a-binary-tree) | Medium | +| 1661 | [Average Time of Process per Machine](https://leetcode.com/problems/average-time-of-process-per-machine "每台机器的进程平均运行时间") 🔒 | [MySQL](../problems/average-time-of-process-per-machine) | Easy | +| 1662 | [Check If Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent "检查两个字符串数组是否相等") | [Go](../problems/check-if-two-string-arrays-are-equivalent) | Easy | +| 1663 | [Smallest String With A Given Numeric Value](https://leetcode.com/problems/smallest-string-with-a-given-numeric-value "具有给定数值的最小字符串") | [Go](../problems/smallest-string-with-a-given-numeric-value) | Medium | +| 1664 | [Ways to Make a Fair Array](https://leetcode.com/problems/ways-to-make-a-fair-array "生成平衡数组的方案数") | [Go](../problems/ways-to-make-a-fair-array) | Medium | +| 1665 | [Minimum Initial Energy to Finish Tasks](https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks "完成所有任务的最少初始能量") | [Go](../problems/minimum-initial-energy-to-finish-tasks) | Hard | +| 1666 | [Change the Root of a Binary Tree](https://leetcode.com/problems/change-the-root-of-a-binary-tree "改变二叉树的根节点") 🔒 | [Go](../problems/change-the-root-of-a-binary-tree) | Medium | +| 1667 | [Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table "修复表中的名字") 🔒 | [MySQL](../problems/fix-names-in-a-table) | Easy | +| 1668 | [Maximum Repeating Substring](https://leetcode.com/problems/maximum-repeating-substring "最大重复子字符串") | [Go](../problems/maximum-repeating-substring) | Easy | +| 1669 | [Merge In Between Linked Lists](https://leetcode.com/problems/merge-in-between-linked-lists "合并两个链表") | [Go](../problems/merge-in-between-linked-lists) | Medium | +| 1670 | [Design Front Middle Back Queue](https://leetcode.com/problems/design-front-middle-back-queue "设计前中后队列") | [Go](../problems/design-front-middle-back-queue) | Medium | +| 1671 | [Minimum Number of Removals to Make Mountain Array](https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array "得到山形数组的最少删除次数") | [Go](../problems/minimum-number-of-removals-to-make-mountain-array) | Hard | +| 1672 | [Richest Customer Wealth](https://leetcode.com/problems/richest-customer-wealth "最富有客户的资产总量") | [Go](../problems/richest-customer-wealth) | Easy | +| 1673 | [Find the Most Competitive Subsequence](https://leetcode.com/problems/find-the-most-competitive-subsequence "找出最具竞争力的子序列") | [Go](../problems/find-the-most-competitive-subsequence) | Medium | +| 1674 | [Minimum Moves to Make Array Complementary](https://leetcode.com/problems/minimum-moves-to-make-array-complementary "使数组互补的最少操作次数") | [Go](../problems/minimum-moves-to-make-array-complementary) | Medium | +| 1675 | [Minimize Deviation in Array](https://leetcode.com/problems/minimize-deviation-in-array "数组的最小偏移量") | [Go](../problems/minimize-deviation-in-array) | Hard | +| 1676 | [Lowest Common Ancestor of a Binary Tree IV](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv "二叉树的最近公共祖先 IV") 🔒 | [Go](../problems/lowest-common-ancestor-of-a-binary-tree-iv) | Medium | +| 1677 | [Product's Worth Over Invoices](https://leetcode.com/problems/products-worth-over-invoices "发票中的产品金额") 🔒 | [MySQL](../problems/products-worth-over-invoices) | Easy | +| 1678 | [Goal Parser Interpretation](https://leetcode.com/problems/goal-parser-interpretation "设计 Goal 解析器") | [Go](../problems/goal-parser-interpretation) | Easy | +| 1679 | [Max Number of K-Sum Pairs](https://leetcode.com/problems/max-number-of-k-sum-pairs "K 和数对的最大数目") | [Go](../problems/max-number-of-k-sum-pairs) | Medium | +| 1680 | [Concatenation of Consecutive Binary Numbers](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers "连接连续二进制数字") | [Go](../problems/concatenation-of-consecutive-binary-numbers) | Medium | +| 1681 | [Minimum Incompatibility](https://leetcode.com/problems/minimum-incompatibility "最小不兼容性") | [Go](../problems/minimum-incompatibility) | Hard | +| 1682 | [Longest Palindromic Subsequence II](https://leetcode.com/problems/longest-palindromic-subsequence-ii "最长回文子序列 II") 🔒 | [Go](../problems/longest-palindromic-subsequence-ii) | Medium | +| 1683 | [Invalid Tweets](https://leetcode.com/problems/invalid-tweets "无效的推文") 🔒 | [MySQL](../problems/invalid-tweets) | Easy | +| 1684 | [Count the Number of Consistent Strings](https://leetcode.com/problems/count-the-number-of-consistent-strings "统计一致字符串的数目") | [Go](../problems/count-the-number-of-consistent-strings) | Easy | +| 1685 | [Sum of Absolute Differences in a Sorted Array](https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array "有序数组中差绝对值之和") | [Go](../problems/sum-of-absolute-differences-in-a-sorted-array) | Medium | +| 1686 | [Stone Game VI](https://leetcode.com/problems/stone-game-vi "石子游戏 VI") | [Go](../problems/stone-game-vi) | Medium | +| 1687 | [Delivering Boxes from Storage to Ports](https://leetcode.com/problems/delivering-boxes-from-storage-to-ports "从仓库到码头运输箱子") | [Go](../problems/delivering-boxes-from-storage-to-ports) | Hard | +| 1688 | [Count of Matches in Tournament](https://leetcode.com/problems/count-of-matches-in-tournament "比赛中的配对次数") | [Go](../problems/count-of-matches-in-tournament) | Easy | +| 1689 | [Partitioning Into Minimum Number Of Deci-Binary Numbers](https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers "十-二进制数的最少数目") | [Go](../problems/partitioning-into-minimum-number-of-deci-binary-numbers) | Medium | +| 1690 | [Stone Game VII](https://leetcode.com/problems/stone-game-vii "石子游戏 VII") | [Go](../problems/stone-game-vii) | Medium | +| 1691 | [Maximum Height by Stacking Cuboids](https://leetcode.com/problems/maximum-height-by-stacking-cuboids "堆叠长方体的最大高度") | [Go](../problems/maximum-height-by-stacking-cuboids) | Hard | +| 1692 | [Count Ways to Distribute Candies](https://leetcode.com/problems/count-ways-to-distribute-candies "计算分配糖果的不同方式") 🔒 | [Go](../problems/count-ways-to-distribute-candies) | Hard | +| 1693 | [Daily Leads and Partners](https://leetcode.com/problems/daily-leads-and-partners "每天的领导和合伙人") 🔒 | [MySQL](../problems/daily-leads-and-partners) | Easy | +| 1694 | [Reformat Phone Number](https://leetcode.com/problems/reformat-phone-number "重新格式化电话号码") | [Go](../problems/reformat-phone-number) | Easy | +| 1695 | [Maximum Erasure Value](https://leetcode.com/problems/maximum-erasure-value "删除子数组的最大得分") | [Go](../problems/maximum-erasure-value) | Medium | +| 1696 | [Jump Game VI](https://leetcode.com/problems/jump-game-vi "跳跃游戏 VI") | [Go](../problems/jump-game-vi) | Medium | +| 1697 | [Checking Existence of Edge Length Limited Paths](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths "检查边长度限制的路径是否存在") | [Go](../problems/checking-existence-of-edge-length-limited-paths) | Hard | +| 1698 | [Number of Distinct Substrings in a String](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string "字符串的不同子字符串个数") 🔒 | [Go](../problems/number-of-distinct-substrings-in-a-string) | Medium | +| 1699 | [Number of Calls Between Two Persons](https://leetcode.com/problems/number-of-calls-between-two-persons "两人之间的通话次数") 🔒 | [MySQL](../problems/number-of-calls-between-two-persons) | Medium | +| 1700 | [Number of Students Unable to Eat Lunch](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch "无法吃午餐的学生数量") | [Go](../problems/number-of-students-unable-to-eat-lunch) | Easy | +| 1701 | [Average Waiting Time](https://leetcode.com/problems/average-waiting-time "平均等待时间") | [Go](../problems/average-waiting-time) | Medium | +| 1702 | [Maximum Binary String After Change](https://leetcode.com/problems/maximum-binary-string-after-change "修改后的最大二进制字符串") | [Go](../problems/maximum-binary-string-after-change) | Medium | +| 1703 | [Minimum Adjacent Swaps for K Consecutive Ones](https://leetcode.com/problems/minimum-adjacent-swaps-for-k-consecutive-ones "得到连续 K 个 1 的最少相邻交换次数") | [Go](../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | Hard | +| 1704 | [Determine if String Halves Are Alike](https://leetcode.com/problems/determine-if-string-halves-are-alike "判断字符串的两半是否相似") | [Go](../problems/determine-if-string-halves-are-alike) | Easy | +| 1705 | [Maximum Number of Eaten Apples](https://leetcode.com/problems/maximum-number-of-eaten-apples "吃苹果的最大数目") | [Go](../problems/maximum-number-of-eaten-apples) | Medium | +| 1706 | [Where Will the Ball Fall](https://leetcode.com/problems/where-will-the-ball-fall "球会落何处") | [Go](../problems/where-will-the-ball-fall) | Medium | +| 1707 | [Maximum XOR With an Element From Array](https://leetcode.com/problems/maximum-xor-with-an-element-from-array "与数组中元素的最大异或值") | [Go](../problems/maximum-xor-with-an-element-from-array) | Hard | +| 1708 | [Largest Subarray Length K](https://leetcode.com/problems/largest-subarray-length-k "长度为 K 的最大子数组") 🔒 | [Go](../problems/largest-subarray-length-k) | Easy | +| 1709 | [Biggest Window Between Visits](https://leetcode.com/problems/biggest-window-between-visits "访问日期之间最大的空档期") 🔒 | [MySQL](../problems/biggest-window-between-visits) | Medium | +| 1710 | [Maximum Units on a Truck](https://leetcode.com/problems/maximum-units-on-a-truck "卡车上的最大单元数") | [Go](../problems/maximum-units-on-a-truck) | Easy | +| 1711 | [Count Good Meals](https://leetcode.com/problems/count-good-meals "大餐计数") | [Go](../problems/count-good-meals) | Medium | +| 1712 | [Ways to Split Array Into Three Subarrays](https://leetcode.com/problems/ways-to-split-array-into-three-subarrays "将数组分成三个子数组的方案数") | [Go](../problems/ways-to-split-array-into-three-subarrays) | Medium | +| 1713 | [Minimum Operations to Make a Subsequence](https://leetcode.com/problems/minimum-operations-to-make-a-subsequence "得到子序列的最少操作次数") | [Go](../problems/minimum-operations-to-make-a-subsequence) | Hard | +| 1714 | [Sum Of Special Evenly-Spaced Elements In Array](https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array "数组中特殊等间距元素的和") 🔒 | [Go](../problems/sum-of-special-evenly-spaced-elements-in-array) | Hard | +| 1715 | [Count Apples and Oranges](https://leetcode.com/problems/count-apples-and-oranges "苹果和橘子的个数") 🔒 | [MySQL](../problems/count-apples-and-oranges) | Medium | +| 1716 | [Calculate Money in Leetcode Bank](https://leetcode.com/problems/calculate-money-in-leetcode-bank "计算力扣银行的钱") | [Go](../problems/calculate-money-in-leetcode-bank) | Easy | +| 1717 | [Maximum Score From Removing Substrings](https://leetcode.com/problems/maximum-score-from-removing-substrings "删除子字符串的最大得分") | [Go](../problems/maximum-score-from-removing-substrings) | Medium | +| 1718 | [Construct the Lexicographically Largest Valid Sequence](https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence "构建字典序最大的可行序列") | [Go](../problems/construct-the-lexicographically-largest-valid-sequence) | Medium | +| 1719 | [Number Of Ways To Reconstruct A Tree](https://leetcode.com/problems/number-of-ways-to-reconstruct-a-tree "重构一棵树的方案数") | [Go](../problems/number-of-ways-to-reconstruct-a-tree) | Hard | +| 1720 | [Decode XORed Array](https://leetcode.com/problems/decode-xored-array "解码异或后的数组") | [Go](../problems/decode-xored-array) | Easy | +| 1721 | [Swapping Nodes in a Linked List](https://leetcode.com/problems/swapping-nodes-in-a-linked-list "交换链表中的节点") | [Go](../problems/swapping-nodes-in-a-linked-list) | Medium | +| 1722 | [Minimize Hamming Distance After Swap Operations](https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations "执行交换操作后的最小汉明距离") | [Go](../problems/minimize-hamming-distance-after-swap-operations) | Medium | +| 1723 | [Find Minimum Time to Finish All Jobs](https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs "完成所有工作的最短时间") | [Go](../problems/find-minimum-time-to-finish-all-jobs) | Hard | +| 1724 | [Checking Existence of Edge Length Limited Paths II](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii "检查边长度限制的路径是否存在 II") 🔒 | [Go](../problems/checking-existence-of-edge-length-limited-paths-ii) | Hard | +| 1725 | [Number Of Rectangles That Can Form The Largest Square](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square "可以形成最大正方形的矩形数目") | [Go](../problems/number-of-rectangles-that-can-form-the-largest-square) | Easy | +| 1726 | [Tuple with Same Product](https://leetcode.com/problems/tuple-with-same-product "同积元组") | [Go](../problems/tuple-with-same-product) | Medium | +| 1727 | [Largest Submatrix With Rearrangements](https://leetcode.com/problems/largest-submatrix-with-rearrangements "重新排列后的最大子矩阵") | [Go](../problems/largest-submatrix-with-rearrangements) | Medium | +| 1728 | [Cat and Mouse II](https://leetcode.com/problems/cat-and-mouse-ii "猫和老鼠 II") | [Go](../problems/cat-and-mouse-ii) | Hard | +| 1729 | [Find Followers Count](https://leetcode.com/problems/find-followers-count "求关注者的数量") 🔒 | [MySQL](../problems/find-followers-count) | Easy | +| 1730 | [Shortest Path to Get Food](https://leetcode.com/problems/shortest-path-to-get-food "获取食物的最短路径") 🔒 | [Go](../problems/shortest-path-to-get-food) | Medium | +| 1731 | [The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee "每位经理的下属员工数量") 🔒 | [MySQL](../problems/the-number-of-employees-which-report-to-each-employee) | Easy | +| 1732 | [Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude "找到最高海拔") | [Go](../problems/find-the-highest-altitude) | Easy | +| 1733 | [Minimum Number of People to Teach](https://leetcode.com/problems/minimum-number-of-people-to-teach "需要教语言的最少人数") | [Go](../problems/minimum-number-of-people-to-teach) | Medium | +| 1734 | [Decode XORed Permutation](https://leetcode.com/problems/decode-xored-permutation "解码异或后的排列") | [Go](../problems/decode-xored-permutation) | Medium | +| 1735 | [Count Ways to Make Array With Product](https://leetcode.com/problems/count-ways-to-make-array-with-product "生成乘积数组的方案数") | [Go](../problems/count-ways-to-make-array-with-product) | Hard | +| 1736 | [Latest Time by Replacing Hidden Digits](https://leetcode.com/problems/latest-time-by-replacing-hidden-digits "替换隐藏数字得到的最晚时间") | [Go](../problems/latest-time-by-replacing-hidden-digits) | Easy | +| 1737 | [Change Minimum Characters to Satisfy One of Three Conditions](https://leetcode.com/problems/change-minimum-characters-to-satisfy-one-of-three-conditions "满足三条件之一需改变的最少字符数") | [Go](../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | Medium | +| 1738 | [Find Kth Largest XOR Coordinate Value](https://leetcode.com/problems/find-kth-largest-xor-coordinate-value "找出第 K 大的异或坐标值") | [Go](../problems/find-kth-largest-xor-coordinate-value) | Medium | +| 1739 | [Building Boxes](https://leetcode.com/problems/building-boxes "放置盒子") | [Go](../problems/building-boxes) | Hard | +| 1740 | [Find Distance in a Binary Tree](https://leetcode.com/problems/find-distance-in-a-binary-tree "找到二叉树中的距离") 🔒 | [Go](../problems/find-distance-in-a-binary-tree) | Medium | +| 1741 | [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee "查找每个员工花费的总时间") 🔒 | [MySQL](../problems/find-total-time-spent-by-each-employee) | Easy | +| 1742 | [Maximum Number of Balls in a Box](https://leetcode.com/problems/maximum-number-of-balls-in-a-box "盒子中小球的最大数量") | [Go](../problems/maximum-number-of-balls-in-a-box) | Easy | +| 1743 | [Restore the Array From Adjacent Pairs](https://leetcode.com/problems/restore-the-array-from-adjacent-pairs "从相邻元素对还原数组") | [Go](../problems/restore-the-array-from-adjacent-pairs) | Medium | +| 1744 | [Can You Eat Your Favorite Candy on Your Favorite Day?](https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day "你能在你最喜欢的那天吃到你最喜欢的糖果吗?") | [Go](../problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | Medium | +| 1745 | [Palindrome Partitioning IV](https://leetcode.com/problems/palindrome-partitioning-iv "回文串分割 IV") | [Go](../problems/palindrome-partitioning-iv) | Hard | +| 1746 | [Maximum Subarray Sum After One Operation](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation "经过一次操作后的最大子数组和") 🔒 | [Go](../problems/maximum-subarray-sum-after-one-operation) | Medium | +| 1747 | [Leetflex Banned Accounts](https://leetcode.com/problems/leetflex-banned-accounts "应该被禁止的Leetflex账户") 🔒 | [MySQL](../problems/leetflex-banned-accounts) | Medium | +| 1748 | [Sum of Unique Elements](https://leetcode.com/problems/sum-of-unique-elements "唯一元素的和") | [Go](../problems/sum-of-unique-elements) | Easy | +| 1749 | [Maximum Absolute Sum of Any Subarray](https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray "任意子数组和的绝对值的最大值") | [Go](../problems/maximum-absolute-sum-of-any-subarray) | Medium | +| 1750 | [Minimum Length of String After Deleting Similar Ends](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends "删除字符串两端相同字符后的最短长度") | [Go](../problems/minimum-length-of-string-after-deleting-similar-ends) | Medium | +| 1751 | [Maximum Number of Events That Can Be Attended II](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended-ii "最多可以参加的会议数目 II") | [Go](../problems/maximum-number-of-events-that-can-be-attended-ii) | Hard | +| 1752 | [Check if Array Is Sorted and Rotated](https://leetcode.com/problems/check-if-array-is-sorted-and-rotated "检查数组是否经排序和轮转得到") | [Go](../problems/check-if-array-is-sorted-and-rotated) | Easy | +| 1753 | [Maximum Score From Removing Stones](https://leetcode.com/problems/maximum-score-from-removing-stones "移除石子的最大得分") | [Go](../problems/maximum-score-from-removing-stones) | Medium | +| 1754 | [Largest Merge Of Two Strings](https://leetcode.com/problems/largest-merge-of-two-strings "构造字典序最大的合并字符串") | [Go](../problems/largest-merge-of-two-strings) | Medium | +| 1755 | [Closest Subsequence Sum](https://leetcode.com/problems/closest-subsequence-sum "最接近目标值的子序列和") | [Go](../problems/closest-subsequence-sum) | Hard | +| 1756 | [Design Most Recently Used Queue](https://leetcode.com/problems/design-most-recently-used-queue "设计最近使用(MRU)队列") 🔒 | [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 | +| 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 | +| 1759 | [Count Number of Homogenous Substrings](https://leetcode.com/problems/count-number-of-homogenous-substrings "统计同构子字符串的数目") | [Go](../problems/count-number-of-homogenous-substrings) | Medium | +| 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 | +| 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 | +| 1762 | [Buildings With an Ocean View](https://leetcode.com/problems/buildings-with-an-ocean-view "能看到海景的建筑物") 🔒 | [Go](../problems/buildings-with-an-ocean-view) | Medium | +| 1763 | [Longest Nice Substring](https://leetcode.com/problems/longest-nice-substring "最长的美好子字符串") | [Go](../problems/longest-nice-substring) | Easy | +| 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 | +| 1765 | [Map of Highest Peak](https://leetcode.com/problems/map-of-highest-peak "地图中的最高点") | [Go](../problems/map-of-highest-peak) | Medium | +| 1766 | [Tree of Coprimes](https://leetcode.com/problems/tree-of-coprimes "互质树") | [Go](../problems/tree-of-coprimes) | Hard | +| 1767 | [Find the Subtasks That Did Not Execute](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute "寻找没有被执行的任务对") 🔒 | [MySQL](../problems/find-the-subtasks-that-did-not-execute) | Hard | +| 1768 | [Merge Strings Alternately](https://leetcode.com/problems/merge-strings-alternately "交替合并字符串") | [Go](../problems/merge-strings-alternately) | Easy | +| 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 | +| 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 | +| 1771 | [Maximize Palindrome Length From Subsequences](https://leetcode.com/problems/maximize-palindrome-length-from-subsequences "由子序列构造的最长回文串的长度") | [Go](../problems/maximize-palindrome-length-from-subsequences) | Hard | +| 1772 | [Sort Features by Popularity](https://leetcode.com/problems/sort-features-by-popularity "按受欢迎程度排列功能") 🔒 | [Go](../problems/sort-features-by-popularity) | Medium | +| 1773 | [Count Items Matching a Rule](https://leetcode.com/problems/count-items-matching-a-rule "统计匹配检索规则的物品数量") | [Go](../problems/count-items-matching-a-rule) | Easy | +| 1774 | [Closest Dessert Cost](https://leetcode.com/problems/closest-dessert-cost "最接近目标价格的甜点成本") | [Go](../problems/closest-dessert-cost) | Medium | +| 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 | +| 1776 | [Car Fleet II](https://leetcode.com/problems/car-fleet-ii "车队 II") | [Go](../problems/car-fleet-ii) | Hard | +| 1777 | [Product's Price for Each Store](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格") 🔒 | [MySQL](../problems/products-price-for-each-store) | 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 | +| 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 | +| 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 | +| 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 | +| 1782 | [Count Pairs Of Nodes](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目") | [Go](../problems/count-pairs-of-nodes) | Hard | +| 1783 | [Grand Slam Titles](https://leetcode.com/problems/grand-slam-titles "大满贯数量") 🔒 | [MySQL](../problems/grand-slam-titles) | 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 | +| 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 | +| 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 | +| 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 | +| 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 | +| 1789 | [Primary Department for Each Employee](https://leetcode.com/problems/primary-department-for-each-employee "员工的直属部门") 🔒 | [MySQL](../problems/primary-department-for-each-employee) | Easy | +| 1790 | [Check if One String Swap Can Make Strings Equal](https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal "仅执行一次字符串交换能否使两个字符串相等") | [Go](../problems/check-if-one-string-swap-can-make-strings-equal) | Easy | +| 1791 | [Find Center of Star Graph](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") | [Go](../problems/find-center-of-star-graph) | Easy | +| 1792 | [Maximum Average Pass Ratio](https://leetcode.com/problems/maximum-average-pass-ratio "最大平均通过率") | [Go](../problems/maximum-average-pass-ratio) | Medium | +| 1793 | [Maximum Score of a Good Subarray](https://leetcode.com/problems/maximum-score-of-a-good-subarray "好子数组的最大分数") | [Go](../problems/maximum-score-of-a-good-subarray) | Hard | +| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference "统计距离最小的子串对个数") 🔒 | [Go](../problems/count-pairs-of-equal-substrings-with-minimum-difference) | Medium | +| 1795 | [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table "每个产品在不同商店的价格") 🔒 | [MySQL](../problems/rearrange-products-table) | Easy | +| 1796 | [Second Largest Digit in a String](https://leetcode.com/problems/second-largest-digit-in-a-string "字符串中第二大的数字") | [Go](../problems/second-largest-digit-in-a-string) | Easy | +| 1797 | [Design Authentication Manager](https://leetcode.com/problems/design-authentication-manager "设计一个验证系统") | [Go](../problems/design-authentication-manager) | Medium | +| 1798 | [Maximum Number of Consecutive Values You Can Make](https://leetcode.com/problems/maximum-number-of-consecutive-values-you-can-make "你能构造出连续值的最大数目") | [Go](../problems/maximum-number-of-consecutive-values-you-can-make) | Medium | +| 1799 | [Maximize Score After N Operations](https://leetcode.com/problems/maximize-score-after-n-operations "N 次操作后的最大分数和") | [Go](../problems/maximize-score-after-n-operations) | Hard | +| 1800 | [Maximum Ascending Subarray Sum](https://leetcode.com/problems/maximum-ascending-subarray-sum "最大升序子数组和") | [Go](../problems/maximum-ascending-subarray-sum) | Easy | diff --git a/readme/301-600.md b/readme/301-600.md index d0b689921..1a0e6f251 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions 323 | [Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph "无向图中连通分量的数目") 🔒 | [Go](../problems/number-of-connected-components-in-an-undirected-graph) | Medium | | 324 | [Wiggle Sort II](https://leetcode.com/problems/wiggle-sort-ii "摆动排序 II") | [Go](../problems/wiggle-sort-ii) | Medium | | 325 | [Maximum Size Subarray Sum Equals k](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k "和等于 k 的最长子数组长度") 🔒 | [Go](../problems/maximum-size-subarray-sum-equals-k) | Medium | -| 326 | [Power of Three](https://leetcode.com/problems/power-of-three "3的幂") | [Go](../problems/power-of-three) | Easy | +| 326 | [Power of Three](https://leetcode.com/problems/power-of-three "3 的幂") | [Go](../problems/power-of-three) | Easy | | 327 | [Count of Range Sum](https://leetcode.com/problems/count-of-range-sum "区间和的个数") | [Go](../problems/count-of-range-sum) | Hard | | 328 | [Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list "奇偶链表") | [Go](../problems/odd-even-linked-list) | Medium | | 329 | [Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix "矩阵中的最长递增路径") | [Go](../problems/longest-increasing-path-in-a-matrix) | Hard | @@ -150,7 +158,7 @@ LeetCode Problems' Solutions | 370 | [Range Addition](https://leetcode.com/problems/range-addition "区间加法") 🔒 | [Go](../problems/range-addition) | Medium | | 371 | [Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers "两整数之和") | [Go](../problems/sum-of-two-integers) | Medium | | 372 | [Super Pow](https://leetcode.com/problems/super-pow "超级次方") | [Go](../problems/super-pow) | Medium | -| 373 | [Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的K对数字") | [Go](../problems/find-k-pairs-with-smallest-sums) | Medium | +| 373 | [Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的 K 对数字") | [Go](../problems/find-k-pairs-with-smallest-sums) | Medium | | 374 | [Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower "猜数字大小") | [Go](../problems/guess-number-higher-or-lower) | Easy | | 375 | [Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii "猜数字大小 II") | [Go](../problems/guess-number-higher-or-lower-ii) | Medium | | 376 | [Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence "摆动序列") | [Go](../problems/wiggle-subsequence) | Medium | diff --git a/readme/601-900.md b/readme/601-900.md index 5ceafc962..91d593fbe 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions 685 | [Redundant Connection II](https://leetcode.com/problems/redundant-connection-ii "冗余连接 II") | [Go](../problems/redundant-connection-ii) | Hard | | 686 | [Repeated String Match](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") | [Go](../problems/repeated-string-match) | Medium | | 687 | [Longest Univalue Path](https://leetcode.com/problems/longest-univalue-path "最长同值路径") | [Go](../problems/longest-univalue-path) | Medium | -| 688 | [Knight Probability in Chessboard](https://leetcode.com/problems/knight-probability-in-chessboard "“马”在棋盘上的概率") | [Go](../problems/knight-probability-in-chessboard) | Medium | +| 688 | [Knight Probability in Chessboard](https://leetcode.com/problems/knight-probability-in-chessboard "骑士在棋盘上的概率") | [Go](../problems/knight-probability-in-chessboard) | Medium | | 689 | [Maximum Sum of 3 Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays "三个无重叠子数组的最大和") | [Go](../problems/maximum-sum-of-3-non-overlapping-subarrays) | Hard | | 690 | [Employee Importance](https://leetcode.com/problems/employee-importance "员工的重要性") | [Go](../problems/employee-importance) | Medium | | 691 | [Stickers to Spell Word](https://leetcode.com/problems/stickers-to-spell-word "贴纸拼词") | [Go](../problems/stickers-to-spell-word) | Hard | @@ -365,7 +373,7 @@ LeetCode Problems' Solutions | 885 | [Spiral Matrix III](https://leetcode.com/problems/spiral-matrix-iii "螺旋矩阵 III") | [Go](../problems/spiral-matrix-iii) | Medium | | 886 | [Possible Bipartition](https://leetcode.com/problems/possible-bipartition "可能的二分法") | [Go](../problems/possible-bipartition) | Medium | | 887 | [Super Egg Drop](https://leetcode.com/problems/super-egg-drop "鸡蛋掉落") | [Go](../problems/super-egg-drop) | Hard | -| 888 | [Fair Candy Swap](https://leetcode.com/problems/fair-candy-swap "公平的糖果棒交换") | [Go](../problems/fair-candy-swap) | Easy | +| 888 | [Fair Candy Swap](https://leetcode.com/problems/fair-candy-swap "公平的糖果交换") | [Go](../problems/fair-candy-swap) | Easy | | 889 | [Construct Binary Tree from Preorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal "根据前序和后序遍历构造二叉树") | [Go](../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | Medium | | 890 | [Find and Replace Pattern](https://leetcode.com/problems/find-and-replace-pattern "查找和替换模式") | [Go](../problems/find-and-replace-pattern) | Medium | | 891 | [Sum of Subsequence Widths](https://leetcode.com/problems/sum-of-subsequence-widths "子序列宽度之和") | [Go](../problems/sum-of-subsequence-widths) | Hard | diff --git a/readme/901-1200.md b/readme/901-1200.md index 56787b7be..d782e4e6a 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions 1031 | [Maximum Sum of Two Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays "两个非重叠子数组的最大和") | [Go](../problems/maximum-sum-of-two-non-overlapping-subarrays) | Medium | | 1032 | [Stream of Characters](https://leetcode.com/problems/stream-of-characters "字符流") | [Go](../problems/stream-of-characters) | Hard | | 1033 | [Moving Stones Until Consecutive](https://leetcode.com/problems/moving-stones-until-consecutive "移动石子直到连续") | [Go](../problems/moving-stones-until-consecutive) | Medium | -| 1034 | [Coloring A Border](https://leetcode.com/problems/coloring-a-border "边框着色") | [Go](../problems/coloring-a-border) | Medium | +| 1034 | [Coloring A Border](https://leetcode.com/problems/coloring-a-border "边界着色") | [Go](../problems/coloring-a-border) | Medium | | 1035 | [Uncrossed Lines](https://leetcode.com/problems/uncrossed-lines "不相交的线") | [Go](../problems/uncrossed-lines) | Medium | | 1036 | [Escape a Large Maze](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫") | [Go](../problems/escape-a-large-maze) | Hard | | 1037 | [Valid Boomerang](https://leetcode.com/problems/valid-boomerang "有效的回旋镖") | [Go](../problems/valid-boomerang) | Easy | @@ -292,7 +300,7 @@ LeetCode Problems' Solutions | 1112 | [Highest Grade For Each Student](https://leetcode.com/problems/highest-grade-for-each-student "每位学生的最高成绩") 🔒 | [MySQL](../problems/highest-grade-for-each-student) | Medium | | 1113 | [Reported Posts](https://leetcode.com/problems/reported-posts "报告的记录") 🔒 | [MySQL](../problems/reported-posts) | Easy | | 1114 | [Print in Order](https://leetcode.com/problems/print-in-order "按序打印") | [Go](../problems/print-in-order) | Easy | -| 1115 | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印FooBar") | [Go](../problems/print-foobar-alternately) | Medium | +| 1115 | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印 FooBar") | [Go](../problems/print-foobar-alternately) | Medium | | 1116 | [Print Zero Even Odd](https://leetcode.com/problems/print-zero-even-odd "打印零与奇偶数") | [Go](../problems/print-zero-even-odd) | Medium | | 1117 | [Building H2O](https://leetcode.com/problems/building-h2o "H2O 生成") | [Go](../problems/building-h2o) | Medium | | 1118 | [Number of Days in a Month](https://leetcode.com/problems/number-of-days-in-a-month "一月有多少天") 🔒 | [Go](../problems/number-of-days-in-a-month) | Easy | diff --git a/tag/array/README.md b/tag/array/README.md index 90abb510d..ef5f632f3 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,62 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2171 | [拿出最少数目的魔法豆](../../problems/removing-minimum-number-of-magic-beans) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2166 | [设计位集](../../problems/design-bitset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 2164 | [对奇偶下标分别排序](../../problems/sort-even-and-odd-indices-independently) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2163 | [删除元素后和的最小差值](../../problems/minimum-difference-in-sums-after-removal-of-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2161 | [根据给定数字划分数组](../../problems/partition-array-according-to-given-pivot) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2158 | [Amount of New Area Painted Each Day](../../problems/amount-of-new-area-painted-each-day) 🔒 | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 2155 | [分组得分最高的所有下标](../../problems/all-divisions-with-the-highest-score-of-a-binary-array) | [[数组](../array/README.md)] | Medium | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2150 | [找出数组中的所有孤独数字](../../problems/find-all-lonely-numbers-in-the-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2149 | [按符号重排数组](../../problems/rearrange-array-elements-by-sign) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2148 | [元素计数](../../problems/count-elements-with-strictly-smaller-and-greater-elements) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2145 | [统计隐藏数组数目](../../problems/count-the-hidden-sequences) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2144 | [打折购买糖果的最小开销](../../problems/minimum-cost-of-buying-candies-with-discount) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2143 | [Choose Numbers From Two Arrays in Range](../../problems/choose-numbers-from-two-arrays-in-range) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2140 | [解决智力问题](../../problems/solving-questions-with-brainpower) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2137 | [Pour Water Between Buckets to Make Water Levels Equal](../../problems/pour-water-between-buckets-to-make-water-levels-equal) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 2136 | [全部开花的最早一天](../../problems/earliest-possible-day-of-full-bloom) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2134 | [最少交换次数来组合所有的 1 II](../../problems/minimum-swaps-to-group-all-1s-together-ii) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2133 | [检查是否每一行每一列都包含全部整数](../../problems/check-if-every-row-and-column-contains-all-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2126 | [摧毁小行星](../../problems/destroying-asteroids) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](../../problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2121 | [相同元素的间隔之和](../../problems/intervals-between-identical-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2114 | [句子中的最多单词数](../../problems/maximum-number-of-words-found-in-sentences) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 2113 | [Elements in Array After Removing and Replacing Elements](../../problems/elements-in-array-after-removing-and-replacing-elements) 🔒 | [[数组](../array/README.md)] | Medium | +| 2111 | [使数组 K 递增的最少操作次数](../../problems/minimum-operations-to-make-the-array-k-increasing) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 2110 | [股票平滑下跌阶段的数目](../../problems/number-of-smooth-descent-periods-of-a-stock) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2109 | [向字符串添加空格](../../problems/adding-spaces-to-a-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2108 | [找出数组中的第一个回文字符串](../../problems/find-first-palindromic-string-in-the-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 2107 | [Number of Unique Flavors After Sharing K Candies](../../problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2105 | [给植物浇水 II](../../problems/watering-plants-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2104 | [子数组范围和](../../problems/sum-of-subarray-ranges) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2100 | [适合打劫银行的日子](../../problems/find-good-days-to-rob-the-bank) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 2098 | [Subsequence of Size K With the Largest Even Sum](../../problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2091 | [从数组中移除最大值和最小值](../../problems/removing-minimum-and-maximum-from-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 2090 | [半径为 k 的子数组平均值](../../problems/k-radius-subarray-averages) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2089 | [找出数组排序后的目标下标](../../problems/find-target-indices-after-sorting-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2088 | [统计农场中肥沃金字塔的数目](../../problems/count-fertile-pyramids-in-a-land) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2087 | [网格图中机器人回家的最小代价](../../problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2079 | [给植物浇水](../../problems/watering-plants) | [[数组](../array/README.md)] | Medium | | 2078 | [两栋颜色不同且距离最远的房子](../../problems/two-furthest-houses-with-different-colors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | @@ -17,32 +73,31 @@ | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 2064 | [分配给商店的最多商品的最小值](../../problems/minimized-maximum-of-products-distributed-to-any-store) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2061 | [扫地机器人清扫过的空间个数](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2059 | [转化数字的最小运算数](../../problems/minimum-operations-to-convert-number) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 2057 | [值相等的最小索引](../../problems/smallest-index-with-equal-value) | [[数组](../array/README.md)] | Easy | | 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | | 2055 | [蜡烛之间的盘子](../../problems/plates-between-candles) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | -| 2052 | [Minimum Cost to Separate Sentence Into Rows](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2052 | [将句子分隔成行的最低成本](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2044 | [统计按位或能得到最大值的子集数目](../../problems/count-number-of-maximum-bitwise-or-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2040 | [两个有序数组的第 K 小乘积](../../problems/kth-smallest-product-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 2037 | [使每位学生都有座位的最少移动次数](../../problems/minimum-number-of-moves-to-seat-everyone) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | -| 2036 | [Maximum Alternating Subarray Sum](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2036 | [最大交替子数组和](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2032 | [至少在两个数组中出现的值](../../problems/two-out-of-three) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 2029 | [石子游戏 IX](../../problems/stone-game-ix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 2028 | [找出缺失的观测数据](../../problems/find-missing-observations) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2023 | [连接后等于目标字符串的字符串对](../../problems/number-of-pairs-of-strings-with-concatenation-equal-to-target) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 2022 | [将一维数组转变成二维数组](../../problems/convert-1d-array-into-2d-array) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | -| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2021 | [街上最亮的位置](../../problems/brightest-position-on-street) 🔒 | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 2017 | [网格游戏](../../problems/grid-game) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | @@ -54,7 +109,7 @@ | 2009 | [使数组连续的最少操作数](../../problems/minimum-number-of-operations-to-make-array-continuous) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | | 2007 | [从双倍数组中还原原数组](../../problems/find-original-array-from-doubled-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | -| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] | Easy | +| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 1997 | [访问完所有房间的第一天](../../problems/first-day-where-you-have-been-in-all-the-rooms) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -65,7 +120,7 @@ | 1991 | [找到数组的中间位置](../../problems/find-the-middle-index-in-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1982 | [从子集的和还原数组](../../problems/find-array-given-subset-sums) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | | 1981 | [最小化目标值与所选元素的差](../../problems/minimize-the-difference-between-target-and-chosen-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1980 | [找出不同的二进制字符串](../../problems/find-unique-binary-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | @@ -89,9 +144,10 @@ | 1943 | [描述绘画结果](../../problems/describe-the-painting) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 1936 | [新增的最少台阶数](../../problems/add-minimum-number-of-rungs) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1929 | [数组串联](../../problems/concatenation-of-array) | [[数组](../array/README.md)] | Easy | | 1926 | [迷宫中离入口最近的出口](../../problems/nearest-exit-from-entrance-in-maze) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1924 | [安装栅栏 II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1920 | [基于排列构建数组](../../problems/build-array-from-permutation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | @@ -114,7 +170,7 @@ | 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | | 1887 | [使数组元素相等的减少操作次数](../../problems/reduction-operations-to-make-the-array-elements-equal) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1886 | [判断矩阵经轮转后是否一致](../../problems/determine-whether-matrix-can-be-obtained-by-rotation) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | -| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1885 | [统计数对](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1883 | [准时抵达会议现场的最小跳过休息次数](../../problems/minimum-skips-to-arrive-at-meeting-on-time) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1882 | [使用服务器处理任务](../../problems/process-tasks-using-servers) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | @@ -146,7 +202,7 @@ | 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 1826 | [有缺陷的传感器](../../problems/faulty-sensor) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1822 | [数组元素积的符号](../../problems/sign-of-the-product-of-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1820 | [最多邀请的个数](../../problems/maximum-number-of-accepted-invitations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | @@ -262,6 +318,7 @@ | 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | @@ -274,7 +331,7 @@ | 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | @@ -370,7 +427,7 @@ | 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1380 | [矩阵中的幸运数](../../problems/lucky-numbers-in-a-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | -| 1375 | [灯泡开关 III](../../problems/bulb-switcher-iii) | [[数组](../array/README.md)] | Medium | +| 1375 | [二进制字符串前缀一致的次数](../../problems/number-of-times-binary-string-is-prefix-aligned) | [[数组](../array/README.md)] | Medium | | 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | | 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -517,7 +574,7 @@ | 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 1035 | [不相交的线](../../problems/uncrossed-lines) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1032 | [字符流](../../problems/stream-of-characters) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[数据流](../data-stream/README.md)] | Hard | | 1031 | [两个非重叠子数组的最大和](../../problems/maximum-sum-of-two-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -610,7 +667,7 @@ | 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 885 | [螺旋矩阵 III](../../problems/spiral-matrix-iii) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 883 | [三维形体投影面积](../../problems/projection-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -626,7 +683,7 @@ | 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 860 | [柠檬水找零](../../problems/lemonade-change) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 853 | [车队](../../problems/car-fleet) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 852 | [山脉数组的峰顶索引](../../problems/peak-index-in-a-mountain-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] | Medium | | 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] | Hard | @@ -649,7 +706,7 @@ | 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Hard | | 809 | [情感丰富的文字](../../problems/expressive-words) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 807 | [保持城市天际线](../../problems/max-increase-to-keep-city-skyline) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -664,6 +721,7 @@ | 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 774 | [最小化去加油站的最大距离](../../problems/minimize-max-distance-to-gas-station) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | @@ -680,6 +738,7 @@ | 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 749 | [隔离病毒](../../problems/contain-virus) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 744 | [寻找比目标字母大的最小字母](../../problems/find-smallest-letter-greater-than-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | @@ -835,7 +894,7 @@ | 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 377 | [组合总和 Ⅳ](../../problems/combination-sum-iv) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 373 | [查找和最小的 K 对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 370 | [区间加法](../../problems/range-addition) 🔒 | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | | 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | @@ -877,7 +936,7 @@ | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -923,7 +982,7 @@ | 174 | [地下城游戏](../../problems/dungeon-game) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 169 | [多数元素](../../problems/majority-element) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 164 | [最大间距](../../problems/maximum-gap) | [[数组](../array/README.md)] [[桶排序](../bucket-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] | Hard | | 163 | [缺失的区间](../../problems/missing-ranges) 🔒 | [[数组](../array/README.md)] | Easy | | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -931,6 +990,7 @@ | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | | 137 | [只出现一次的数字 II](../../problems/single-number-ii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Medium | | 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | | 135 | [分发糖果](../../problems/candy) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Hard | @@ -966,7 +1026,7 @@ | 56 | [合并区间](../../problems/merge-intervals) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 55 | [跳跃游戏](../../problems/jump-game) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 53 | [最大子数组和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 51 | [N 皇后](../../problems/n-queens) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 47 | [全排列 II](../../problems/permutations-ii) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index b864fa7ec..88a033751 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | @@ -26,6 +28,7 @@ | 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Hard | | 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | @@ -72,6 +75,7 @@ | 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 282 | [给表达式添加运算符](../../problems/expression-add-operators) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[数组](../array/README.md)] [[回溯](../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)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md index 350e34ae8..efb68694d 100644 --- a/tag/binary-indexed-tree/README.md +++ b/tag/binary-indexed-tree/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1964 | [找出到每个位置为止最长的有效障碍赛跑路线](../../problems/find-the-longest-valid-obstacle-course-at-each-position) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index 3a558f6de..a52f03e70 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[贪心](../greedy/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 3205ba91a..9b634cc8e 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2137 | [Pour Water Between Buckets to Make Water Levels Equal](../../problems/pour-water-between-buckets-to-make-water-levels-equal) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 2111 | [使数组 K 递增的最少操作次数](../../problems/minimum-operations-to-make-the-array-k-increasing) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2089 | [找出数组排序后的目标下标](../../problems/find-target-indices-after-sorting-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -17,7 +22,7 @@ | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2040 | [两个有序数组的第 K 小乘积](../../problems/kth-smallest-product-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 2009 | [使数组连续的最少操作数](../../problems/minimum-number-of-operations-to-make-array-continuous) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -33,7 +38,7 @@ | 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1891 | [割绳子](../../problems/cutting-ribbons) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | -| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1885 | [统计数对](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1870 | [准时到达的列车最小时速](../../problems/minimum-speed-to-arrive-on-time) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1862 | [向下取整数对和](../../problems/sum-of-floored-pairs) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -104,7 +109,7 @@ | 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 911 | [在线选举](../../problems/online-election) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 875 | [爱吃香蕉的珂珂](../../problems/koko-eating-bananas) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -161,13 +166,13 @@ | 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 69 | [Sqrt(x)](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 69 | [x 的平方根 ](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/binary-tree/README.md b/tag/binary-tree/README.md index 9cea043e7..3fa30ffc7 100644 --- a/tag/binary-tree/README.md +++ b/tag/binary-tree/README.md @@ -9,9 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -44,7 +45,7 @@ | 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -124,7 +125,7 @@ | 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -139,11 +140,11 @@ | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/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)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/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)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index f008e795e..aef205ab6 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2157 | [字符串分组](../../problems/groups-of-strings) | [[位运算](../bit-manipulation/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 2044 | [统计按位或能得到最大值的子集数目](../../problems/count-number-of-maximum-bitwise-or-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | @@ -39,7 +45,7 @@ | 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/bitmask/README.md b/tag/bitmask/README.md index 056368cdd..c13f4838e 100644 --- a/tag/bitmask/README.md +++ b/tag/bitmask/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1994 | [好子集的数目](../../problems/the-number-of-good-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 54cf36cd5..4e9f76243 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,8 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2059 | [转化数字的最小运算数](../../problems/minimum-operations-to-convert-number) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -76,7 +79,7 @@ | 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1197 | [进击的骑士](../../problems/minimum-knight-moves) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -85,7 +88,7 @@ | 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | @@ -189,8 +192,9 @@ | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/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)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/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)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | diff --git a/tag/concurrency/README.md b/tag/concurrency/README.md index 6ad20643a..2155bbd8d 100644 --- a/tag/concurrency/README.md +++ b/tag/concurrency/README.md @@ -16,5 +16,5 @@ | 1188 | [设计有限阻塞队列](../../problems/design-bounded-blocking-queue) 🔒 | [[多线程](../concurrency/README.md)] | Medium | | 1117 | [H2O 生成](../../problems/building-h2o) | [[多线程](../concurrency/README.md)] | Medium | | 1116 | [打印零与奇偶数](../../problems/print-zero-even-odd) | [[多线程](../concurrency/README.md)] | Medium | -| 1115 | [交替打印FooBar](../../problems/print-foobar-alternately) | [[多线程](../concurrency/README.md)] | Medium | +| 1115 | [交替打印 FooBar](../../problems/print-foobar-alternately) | [[多线程](../concurrency/README.md)] | Medium | | 1114 | [按序打印](../../problems/print-in-order) | [[多线程](../concurrency/README.md)] | Easy | diff --git a/tag/counting/README.md b/tag/counting/README.md index 111d9c1de..c1807c731 100644 --- a/tag/counting/README.md +++ b/tag/counting/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2150 | [找出数组中的所有孤独数字](../../problems/find-all-lonely-numbers-in-the-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | @@ -16,6 +22,7 @@ | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2014 | [重复 K 次的最长子序列](../../problems/longest-subsequence-repeated-k-times) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1941 | [检查是否所有字符出现次数相同](../../problems/check-if-all-characters-have-equal-number-of-occurrences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | @@ -58,6 +65,7 @@ | 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | | 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 621 | [任务调度器](../../problems/task-scheduler) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/data-stream/README.md b/tag/data-stream/README.md index 1f6d61328..c7bd52e2a 100644 --- a/tag/data-stream/README.md +++ b/tag/data-stream/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | | 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 6174bf935..025044f79 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2127 | [参加会议的最多员工数](../../problems/maximum-employees-to-be-invited-to-a-meeting) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2097 | [合法重新排列数对](../../problems/valid-arrangement-of-pairs) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -75,6 +80,7 @@ | 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | | 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[双连通分量](../biconnected-component/README.md)] | Hard | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -85,7 +91,7 @@ | 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/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)] [[二叉树](../binary-tree/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | @@ -208,7 +214,7 @@ | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 235 | [二叉搜索树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | @@ -227,11 +233,11 @@ | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/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)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/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)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | diff --git a/tag/design/README.md b/tag/design/README.md index e62692267..2dc5e63d6 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,10 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2166 | [设计位集](../../problems/design-bitset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2069 | [模拟行走机器人 II](../../problems/walking-robot-simulation-ii) | [[设计](../design/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | @@ -99,7 +101,7 @@ | 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[设计](../design/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | @@ -111,4 +113,4 @@ | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 6e1eebbbb..e8c6de06d 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1982 | [从子集的和还原数组](../../problems/find-array-given-subset-sums) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | | 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -43,6 +43,6 @@ | 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 53 | [最大子数组和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/doubly-linked-list/README.md b/tag/doubly-linked-list/README.md index 104be93b5..2e57a2202 100644 --- a/tag/doubly-linked-list/README.md +++ b/tag/doubly-linked-list/README.md @@ -15,4 +15,4 @@ | 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Hard | | 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | | 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index e156b1010..3e539a824 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,12 +9,23 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2167 | [移除所有载有违禁货物车厢所需的最少时间](../../problems/minimum-time-to-remove-all-cars-containing-illegal-goods) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2163 | [删除元素后和的最小差值](../../problems/minimum-difference-in-sums-after-removal-of-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2147 | [分隔长廊的方案数](../../problems/number-of-ways-to-divide-a-long-corridor) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2143 | [Choose Numbers From Two Arrays in Range](../../problems/choose-numbers-from-two-arrays-in-range) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2140 | [解决智力问题](../../problems/solving-questions-with-brainpower) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2110 | [股票平滑下跌阶段的数目](../../problems/number-of-smooth-descent-periods-of-a-stock) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2100 | [适合打劫银行的日子](../../problems/find-good-days-to-rob-the-bank) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2088 | [统计农场中肥沃金字塔的数目](../../problems/count-fertile-pyramids-in-a-land) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2086 | [从房屋收集雨水需要的最少水桶数](../../problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2063 | [所有子字符串中的元音](../../problems/vowels-of-all-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 2060 | [同源字符串检测](../../problems/check-if-an-original-string-exists-given-two-encoded-strings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2052 | [Minimum Cost to Separate Sentence Into Rows](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2052 | [将句子分隔成行的最低成本](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 2036 | [Maximum Alternating Subarray Sum](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2036 | [最大交替子数组和](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -85,7 +96,7 @@ | 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -237,7 +248,7 @@ | 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 688 | [“马”在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 688 | [骑士在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 664 | [奇怪的打印机](../../problems/strange-printer) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -278,7 +289,7 @@ | 458 | [可怜的小猪](../../problems/poor-pigs) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 446 | [等差数列划分 II - 子序列](../../problems/arithmetic-slices-ii-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | -| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Medium | | 416 | [分割等和子集](../../problems/partition-equal-subset-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -343,7 +354,7 @@ | 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 62 | [不同路径](../../problems/unique-paths) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 55 | [跳跃游戏](../../problems/jump-game) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 53 | [最大子数组和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | diff --git a/tag/enumeration/README.md b/tag/enumeration/README.md index cfa2fed90..ff12a4344 100644 --- a/tag/enumeration/README.md +++ b/tag/enumeration/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2162 | [设置时间的最少代价](../../problems/minimum-cost-to-set-cooking-time) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | | 2081 | [k 镜像数字的和](../../problems/sum-of-k-mirror-numbers) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | @@ -20,7 +24,7 @@ | 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | -| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1566 | [重复至少 K 次且长度为 M 的模式](../../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1534 | [统计好三元组](../../problems/count-good-triplets) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1291 | [顺次数](../../problems/sequential-digits) | [[枚举](../enumeration/README.md)] | Medium | diff --git a/tag/eulerian-circuit/README.md b/tag/eulerian-circuit/README.md index f48b4407a..a616dce95 100644 --- a/tag/eulerian-circuit/README.md +++ b/tag/eulerian-circuit/README.md @@ -9,5 +9,6 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2097 | [合法重新排列数对](../../problems/valid-arrangement-of-pairs) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | | 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | | 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 3bb8dcf8f..e2465ee41 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,8 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1956 | [感染 K 种病毒所需的最短时间](../../problems/minimum-time-for-k-virus-variants-to-spread) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[枚举](../enumeration/README.md)] | Hard | -| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1924 | [安装栅栏 II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | | 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Hard | @@ -34,4 +36,4 @@ | 469 | [凸多边形](../../problems/convex-polygon) 🔒 | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | | 335 | [路径交叉](../../problems/self-crossing) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 223 | [矩形面积](../../problems/rectangle-area) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 2c116d55e..7fb9edbc3 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,11 +9,18 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2127 | [参加会议的最多员工数](../../problems/maximum-employees-to-be-invited-to-a-meeting) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](../../problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2097 | [合法重新排列数对](../../problems/valid-arrangement-of-pairs) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | +| 2093 | [Minimum Cost to Reach City With Discounts](../../problems/minimum-cost-to-reach-city-with-discounts) 🔒 | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2077 | [Paths in Maze That Lead to Same Room](../../problems/paths-in-maze-that-lead-to-same-room) 🔒 | [[图](../graph/README.md)] | Medium | | 2076 | [处理含限制条件的好友请求](../../problems/process-restricted-friend-requests) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1971 | [寻找图中是否存在路径](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 0d5ade543..273b006ac 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,20 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2160 | [拆分数位后四位数字的最小和](../../problems/minimum-sum-of-four-digit-number-after-splitting-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2144 | [打折购买糖果的最小开销](../../problems/minimum-cost-of-buying-candies-with-discount) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2139 | [得到目标值的最少行动次数](../../problems/minimum-moves-to-reach-target-score) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 2136 | [全部开花的最早一天](../../problems/earliest-possible-day-of-full-bloom) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2126 | [摧毁小行星](../../problems/destroying-asteroids) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2116 | [判断一个括号字符串是否有效](../../problems/check-if-a-parentheses-string-can-be-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 2098 | [Subsequence of Size K With the Largest Even Sum](../../problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2091 | [从数组中移除最大值和最小值](../../problems/removing-minimum-and-maximum-from-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 2087 | [网格图中机器人回家的最小代价](../../problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2086 | [从房屋收集雨水需要的最少水桶数](../../problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2078 | [两栋颜色不同且距离最远的房子](../../problems/two-furthest-houses-with-different-colors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2038 | [如果相邻两个颜色均相同则删除当前颜色](../../problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -26,6 +40,7 @@ | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1953 | [你可以工作的最大周数](../../problems/maximum-number-of-weeks-for-which-you-can-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1946 | [子字符串突变后可能得到的最大整数](../../problems/largest-number-after-mutating-substring) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1936 | [新增的最少台阶数](../../problems/add-minimum-number-of-rungs) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1903 | [字符串中的最大奇数](../../problems/largest-odd-number-in-string) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | @@ -78,7 +93,7 @@ | 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | | 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1564 | [把箱子放进仓库里 I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -87,7 +102,7 @@ | 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1537 | [最大得分](../../problems/get-the-maximum-score) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1529 | [最少的后缀翻转次数](../../problems/minimum-suffix-flips) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | | 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -161,7 +176,7 @@ | 846 | [一手顺子](../../problems/hand-of-straights) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | | 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 807 | [保持城市天际线](../../problems/max-increase-to-keep-city-skyline) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/hash-function/README.md b/tag/hash-function/README.md index 7061229ce..15abea6e7 100644 --- a/tag/hash-function/README.md +++ b/tag/hash-function/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 1960 | [两个回文子字符串长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-substrings) | [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index ac840e676..d0645f16b 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,16 +9,35 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2166 | [设计位集](../../problems/design-bitset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2150 | [找出数组中的所有孤独数字](../../problems/find-all-lonely-numbers-in-the-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2133 | [检查是否每一行每一列都包含全部整数](../../problems/check-if-every-row-and-column-contains-all-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2121 | [相同元素的间隔之和](../../problems/intervals-between-identical-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2107 | [Number of Unique Flavors After Sharing K Candies](../../problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2103 | [环和杆](../../problems/rings-and-rods) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2062 | [统计字符串中的元音子字符串](../../problems/count-vowel-substrings-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2032 | [至少在两个数组中出现的值](../../problems/two-out-of-three) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 2007 | [从双倍数组中还原原数组](../../problems/find-original-array-from-doubled-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | @@ -194,7 +213,7 @@ | 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/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)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -206,11 +225,11 @@ | 819 | [最常见的单词](../../problems/most-common-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 817 | [链表组件](../../problems/linked-list-components) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | | 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 792 | [匹配子序列的单词数](../../problems/number-of-matching-subsequences) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -218,12 +237,12 @@ | 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | | 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 740 | [删除并获得点数](../../problems/delete-and-earn) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | | 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[随机化](../randomized/README.md)] | Hard | @@ -327,8 +346,8 @@ | 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | | 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 141 | [环形链表](../../problems/linked-list-cycle) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 140 | [单词拆分 II](../../problems/word-break-ii) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Hard | diff --git a/tag/heap-priority-queue/README.md b/tag/heap-priority-queue/README.md index c5868632c..04cdd71aa 100644 --- a/tag/heap-priority-queue/README.md +++ b/tag/heap-priority-queue/README.md @@ -9,8 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2163 | [删除元素后和的最小差值](../../problems/minimum-difference-in-sums-after-removal-of-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1962 | [移除石子使总数最小](../../problems/remove-stones-to-minimize-the-total) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -94,7 +98,7 @@ | 420 | [强密码检验器](../../problems/strong-password-checker) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 373 | [查找和最小的 K 对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 355 | [设计推特](../../problems/design-twitter) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/iterator/README.md b/tag/iterator/README.md index 641c321ca..0b206b29a 100644 --- a/tag/iterator/README.md +++ b/tag/iterator/README.md @@ -14,7 +14,7 @@ | 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[迭代器](../iterator/README.md)] | Easy | | 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] [[迭代器](../iterator/README.md)] | Medium | -| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index c58530bba..9a8521393 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,9 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2130 | [链表最大孪生和](../../problems/maximum-twin-sum-of-a-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2095 | [删除链表的中间节点](../../problems/delete-the-middle-node-of-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 2074 | [反转偶数长度组的节点](../../problems/reverse-nodes-in-even-length-groups) | [[链表](../linked-list/README.md)] | Medium | | 2058 | [找出临界点之间的最小和最大距离](../../problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points) | [[链表](../linked-list/README.md)] | Medium | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2046 | [给按照绝对值排序的链表排序](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1836 | [从未排序的链表中移除重复元素](../../problems/remove-duplicates-from-an-unsorted-linked-list) 🔒 | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | | 1721 | [交换链表中的节点](../../problems/swapping-nodes-in-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | @@ -52,11 +54,13 @@ | 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 148 | [排序链表](../../problems/sort-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[分治](../divide-and-conquer/README.md)] [[排序](../sorting/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[链表](../linked-list/README.md)] [[排序](../sorting/README.md)] | Medium | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | | 143 | [重排链表](../../problems/reorder-list) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 141 | [环形链表](../../problems/linked-list-cycle) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/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)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 92 | [反转链表 II](../../problems/reverse-linked-list-ii) | [[链表](../linked-list/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 053a05c92..da2c17d3e 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,20 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2169 | [得到 0 的操作数](../../problems/count-operations-to-obtain-zero) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2165 | [重排数字的最小值](../../problems/smallest-value-of-the-rearranged-number) | [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2162 | [设置时间的最少代价](../../problems/minimum-cost-to-set-cooking-time) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 2160 | [拆分数位后四位数字的最小和](../../problems/minimum-sum-of-four-digit-number-after-splitting-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2147 | [分隔长廊的方案数](../../problems/number-of-ways-to-divide-a-long-corridor) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2139 | [得到目标值的最少行动次数](../../problems/minimum-moves-to-reach-target-score) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2119 | [反转两次的数字](../../problems/a-number-after-a-double-reversal) | [[数学](../math/README.md)] | Easy | +| 2117 | [一个区间内所有数乘积的缩写](../../problems/abbreviating-the-product-of-a-range) | [[数学](../math/README.md)] | Hard | +| 2110 | [股票平滑下跌阶段的数目](../../problems/number-of-smooth-descent-periods-of-a-stock) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2081 | [k 镜像数字的和](../../problems/sum-of-k-mirror-numbers) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2063 | [所有子字符串中的元音](../../problems/vowels-of-all-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | @@ -27,7 +41,7 @@ | 1952 | [三除数](../../problems/three-divisors) | [[数学](../math/README.md)] | Easy | | 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | -| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1924 | [安装栅栏 II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1922 | [统计好数字的数目](../../problems/count-good-numbers) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1908 | [Nim 游戏 II](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -45,7 +59,7 @@ | 1835 | [所有数对按位与结果的异或和](../../problems/find-xor-sum-of-all-pairs-bitwise-and) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1822 | [数组元素积的符号](../../problems/sign-of-the-product-of-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Medium | @@ -97,7 +111,7 @@ | 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Hard | | 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] | Medium | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | | 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | @@ -212,7 +226,7 @@ | 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 788 | [旋转数字](../../problems/rotated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Hard | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 780 | [到达终点](../../problems/reaching-points) | [[数学](../math/README.md)] | Hard | | 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | @@ -293,7 +307,7 @@ | 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 335 | [路径交叉](../../problems/self-crossing) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 326 | [3的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | +| 326 | [3 的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | | 313 | [超级丑数](../../problems/super-ugly-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Hard | @@ -320,11 +334,11 @@ | 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | | 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 89 | [格雷编码](../../problems/gray-code) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 70 | [爬楼梯](../../problems/climbing-stairs) | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 69 | [Sqrt(x)](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 69 | [x 的平方根 ](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 67 | [二进制求和](../../problems/add-binary) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 66 | [加一](../../problems/plus-one) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 62 | [不同路径](../../problems/unique-paths) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | @@ -336,5 +350,5 @@ | 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 9 | [回文数](../../problems/palindrome-number) | [[数学](../math/README.md)] | Easy | -| 7 | [整数反转](../../problems/reverse-integer) | [[数学](../math/README.md)] | Easy | +| 7 | [整数反转](../../problems/reverse-integer) | [[数学](../math/README.md)] | Medium | | 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/matrix/README.md b/tag/matrix/README.md index f1af6860d..8b27d5128 100644 --- a/tag/matrix/README.md +++ b/tag/matrix/README.md @@ -9,7 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2133 | [检查是否每一行每一列都包含全部整数](../../problems/check-if-every-row-and-column-contains-all-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](../../problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2088 | [统计农场中肥沃金字塔的数目](../../problems/count-fertile-pyramids-in-a-land) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2087 | [网格图中机器人回家的最小代价](../../problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2061 | [扫地机器人清扫过的空间个数](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2022 | [将一维数组转变成二维数组](../../problems/convert-1d-array-into-2d-array) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -81,7 +89,7 @@ | 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | | 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | diff --git a/tag/merge-sort/README.md b/tag/merge-sort/README.md index 87b8fff12..81df28808 100644 --- a/tag/merge-sort/README.md +++ b/tag/merge-sort/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 912 | [排序数组](../../problems/sort-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数排序](../counting-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 493 | [翻转对](../../problems/reverse-pairs) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/monotonic-stack/README.md b/tag/monotonic-stack/README.md index 69ccccc69..b609198b4 100644 --- a/tag/monotonic-stack/README.md +++ b/tag/monotonic-stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2104 | [子数组范围和](../../problems/sum-of-subarray-ranges) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1950 | [所有子数组最小值中的最大值](../../problems/maximum-of-minimum-values-in-all-subarrays) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | @@ -32,6 +33,7 @@ | 962 | [最大宽度坡](../../problems/maximum-width-ramp) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 901 | [股票价格跨度](../../problems/online-stock-span) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | diff --git a/tag/number-theory/README.md b/tag/number-theory/README.md index 47d79b04e..07cf48872 100644 --- a/tag/number-theory/README.md +++ b/tag/number-theory/README.md @@ -12,6 +12,7 @@ | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1250 | [检查「好数组」](../../problems/check-if-it-is-a-good-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[数论](../number-theory/README.md)] | Medium | | 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | diff --git a/tag/ordered-set/README.md b/tag/ordered-set/README.md index 7665f8456..45db4a2aa 100644 --- a/tag/ordered-set/README.md +++ b/tag/ordered-set/README.md @@ -9,13 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2158 | [Amount of New Area Painted Each Day](../../problems/amount-of-new-area-painted-each-day) 🔒 | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | -| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2021 | [街上最亮的位置](../../problems/brightest-position-on-street) 🔒 | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | | 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | diff --git a/tag/prefix-sum/README.md b/tag/prefix-sum/README.md index 82e3e9c76..07ca36a90 100644 --- a/tag/prefix-sum/README.md +++ b/tag/prefix-sum/README.md @@ -9,11 +9,18 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2171 | [拿出最少数目的魔法豆](../../problems/removing-minimum-number-of-magic-beans) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2145 | [统计隐藏数组数目](../../problems/count-the-hidden-sequences) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2121 | [相同元素的间隔之和](../../problems/intervals-between-identical-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2100 | [适合打劫银行的日子](../../problems/find-good-days-to-rob-the-bank) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2055 | [蜡烛之间的盘子](../../problems/plates-between-candles) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2021 | [街上最亮的位置](../../problems/brightest-position-on-street) 🔒 | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2017 | [网格游戏](../../problems/grid-game) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1991 | [找到数组的中间位置](../../problems/find-the-middle-index-in-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1943 | [描述绘画结果](../../problems/describe-the-painting) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index d76a040d3..2db4c7d3d 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -12,6 +12,7 @@ | 2073 | [买票需要的时间](../../problems/time-needed-to-buy-tickets) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[栈](../stack/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 1696 | [跳跃游戏 VI](../../problems/jump-game-vi) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 9e3769198..c6113caa1 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -11,7 +11,7 @@ | :-: | - | - | :-: | | 1969 | [数组元素的最小非零乘积](../../problems/minimum-non-zero-product-of-the-array-elements) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1922 | [统计好数字的数目](../../problems/count-good-numbers) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1808 | [好因子的最大数目](../../problems/maximize-number-of-nice-divisors) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | | 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | | 1265 | [逆序打印不可变链表](../../problems/print-immutable-linked-list-in-reverse) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | @@ -30,7 +30,7 @@ | 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | | 344 | [反转字符串](../../problems/reverse-string) | [[递归](../recursion/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | -| 326 | [3的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | +| 326 | [3 的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | diff --git a/tag/rolling-hash/README.md b/tag/rolling-hash/README.md index 85629bdc3..929c4e240 100644 --- a/tag/rolling-hash/README.md +++ b/tag/rolling-hash/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 1960 | [两个回文子字符串长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-substrings) | [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index 872832452..d15fa7dfa 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,8 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2158 | [Amount of New Area Painted Each Day](../../problems/amount-of-new-area-painted-each-day) 🔒 | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/shortest-path/README.md b/tag/shortest-path/README.md index a1cacef5d..09e0f7c25 100644 --- a/tag/shortest-path/README.md +++ b/tag/shortest-path/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2093 | [Minimum Cost to Reach City With Discounts](../../problems/minimum-cost-to-reach-city-with-discounts) 🔒 | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/simulation/README.md b/tag/simulation/README.md index de5ff39b9..06983fe1f 100644 --- a/tag/simulation/README.md +++ b/tag/simulation/README.md @@ -9,10 +9,18 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2169 | [得到 0 的操作数](../../problems/count-operations-to-obtain-zero) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2161 | [根据给定数字划分数组](../../problems/partition-array-according-to-given-pivot) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2149 | [按符号重排数组](../../problems/rearrange-array-elements-by-sign) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2138 | [将字符串拆分为若干长度为 k 的组](../../problems/divide-a-string-into-groups-of-size-k) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2120 | [执行所有后缀指令](../../problems/execution-of-all-suffix-instructions-staying-in-a-grid) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2109 | [向字符串添加空格](../../problems/adding-spaces-to-a-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2105 | [给植物浇水 II](../../problems/watering-plants-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2075 | [解码斜向换位密码](../../problems/decode-the-slanted-ciphertext) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2073 | [买票需要的时间](../../problems/time-needed-to-buy-tickets) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2069 | [模拟行走机器人 II](../../problems/walking-robot-simulation-ii) | [[设计](../design/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2061 | [扫地机器人清扫过的空间个数](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2028 | [找出缺失的观测数据](../../problems/find-missing-observations) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | @@ -23,7 +31,7 @@ | 1914 | [循环轮转矩阵](../../problems/cyclically-rotating-a-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1860 | [增长的内存泄露](../../problems/incremental-memory-leak) | [[模拟](../simulation/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | @@ -74,6 +82,7 @@ | 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 498 | [对角线遍历](../../problems/diagonal-traverse) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Medium | | 415 | [字符串相加](../../problems/add-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 412 | [Fizz Buzz](../../problems/fizz-buzz) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 289 | [生命游戏](../../problems/game-of-life) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 888c73f17..c77329490 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,7 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2134 | [最少交换次数来组合所有的 1 II](../../problems/minimum-swaps-to-group-all-1s-together-ii) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2107 | [Number of Unique Flavors After Sharing K Candies](../../problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2090 | [半径为 k 的子数组平均值](../../problems/k-radius-subarray-averages) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1918 | [第 K 小的子数组和·](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1876 | [长度为三且各字符不同的子字符串](../../problems/substrings-of-size-three-with-distinct-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1852 | [每个子数组的数字种类数](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | diff --git a/tag/sorting/README.md b/tag/sorting/README.md index 1e795d316..0ac1e9083 100644 --- a/tag/sorting/README.md +++ b/tag/sorting/README.md @@ -9,10 +9,28 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2171 | [拿出最少数目的魔法豆](../../problems/removing-minimum-number-of-magic-beans) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2165 | [重排数字的最小值](../../problems/smallest-value-of-the-rearranged-number) | [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2164 | [对奇偶下标分别排序](../../problems/sort-even-and-odd-indices-independently) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2160 | [拆分数位后四位数字的最小和](../../problems/minimum-sum-of-four-digit-number-after-splitting-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2148 | [元素计数](../../problems/count-elements-with-strictly-smaller-and-greater-elements) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2144 | [打折购买糖果的最小开销](../../problems/minimum-cost-of-buying-candies-with-discount) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2136 | [全部开花的最早一天](../../problems/earliest-possible-day-of-full-bloom) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2126 | [摧毁小行星](../../problems/destroying-asteroids) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 2098 | [Subsequence of Size K With the Largest Even Sum](../../problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2089 | [找出数组排序后的目标下标](../../problems/find-target-indices-after-sorting-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2046 | [给按照绝对值排序的链表排序](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 2037 | [使每位学生都有座位的最少移动次数](../../problems/minimum-number-of-moves-to-seat-everyone) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -21,13 +39,13 @@ | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1968 | [构造元素不等于两相邻元素平均值的数组](../../problems/array-with-elements-not-equal-to-average-of-neighbors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1913 | [两个数对之间的最大乘积差](../../problems/maximum-product-difference-between-two-pairs) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | | 1887 | [使数组元素相等的减少操作次数](../../problems/reduction-operations-to-make-the-array-elements-equal) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1885 | [统计数对](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1874 | [两个数组的最小乘积和](../../problems/minimize-product-sum-of-two-arrays) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -140,12 +158,12 @@ | 905 | [按奇偶排序数组](../../problems/sort-array-by-parity) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | | 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Medium | | 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 853 | [车队](../../problems/car-fleet) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 846 | [一手顺子](../../problems/hand-of-straights) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | | 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -158,6 +176,7 @@ | 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 757 | [设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | | 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | | 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | | 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[随机化](../randomized/README.md)] | Hard | diff --git a/tag/stack/README.md b/tag/stack/README.md index 7fe784c89..fa5f7a7cd 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2130 | [链表最大孪生和](../../problems/maximum-twin-sum-of-a-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2116 | [判断一个括号字符串是否有效](../../problems/check-if-a-parentheses-string-can-be-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 2104 | [子数组范围和](../../problems/sum-of-subarray-ranges) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | @@ -69,6 +72,7 @@ | 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 880 | [索引处的解码字符串](../../problems/decoded-string-at-index) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | @@ -77,7 +81,7 @@ | 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 735 | [行星碰撞](../../problems/asteroid-collision) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 716 | [最大栈](../../problems/max-stack) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] [[有序集合](../ordered-set/README.md)] | Easy | | 682 | [棒球比赛](../../problems/baseball-game) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index f61110315..0a015eeb0 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,28 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2167 | [移除所有载有违禁货物车厢所需的最少时间](../../problems/minimum-time-to-remove-all-cars-containing-illegal-goods) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2157 | [字符串分组](../../problems/groups-of-strings) | [[位运算](../bit-manipulation/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2147 | [分隔长廊的方案数](../../problems/number-of-ways-to-divide-a-long-corridor) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2138 | [将字符串拆分为若干长度为 k 的组](../../problems/divide-a-string-into-groups-of-size-k) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2129 | [将标题首字母大写](../../problems/capitalize-the-title) | [[字符串](../string/README.md)] | Easy | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2124 | [检查是否所有 A 都在 B 之前](../../problems/check-if-all-as-appears-before-all-bs) | [[字符串](../string/README.md)] | Easy | +| 2120 | [执行所有后缀指令](../../problems/execution-of-all-suffix-instructions-staying-in-a-grid) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2116 | [判断一个括号字符串是否有效](../../problems/check-if-a-parentheses-string-can-be-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2114 | [句子中的最多单词数](../../problems/maximum-number-of-words-found-in-sentences) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 2109 | [向字符串添加空格](../../problems/adding-spaces-to-a-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2108 | [找出数组中的第一个回文字符串](../../problems/find-first-palindromic-string-in-the-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 2103 | [环和杆](../../problems/rings-and-rods) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 2086 | [从房屋收集雨水需要的最少水桶数](../../problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2075 | [解码斜向换位密码](../../problems/decode-the-slanted-ciphertext) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | @@ -122,7 +144,7 @@ | 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | | 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | | 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | @@ -133,7 +155,7 @@ | 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1529 | [最少的后缀翻转次数](../../problems/minimum-suffix-flips) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1528 | [重新排列字符串](../../problems/shuffle-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | @@ -147,6 +169,7 @@ | 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | | 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1446 | [连续字符](../../problems/consecutive-characters) | [[字符串](../string/README.md)] | Easy | | 1436 | [旅行终点站](../../problems/destination-city) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -291,7 +314,7 @@ | 820 | [单词的压缩编码](../../problems/short-encoding-of-words) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 819 | [最常见的单词](../../problems/most-common-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 809 | [情感丰富的文字](../../problems/expressive-words) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 806 | [写字符串需要的行数](../../problems/number-of-lines-to-write-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | @@ -311,14 +334,14 @@ | 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | | 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 751 | [IP 到 CIDR](../../problems/ip-to-cidr) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 745 | [前缀和后缀搜索](../../problems/prefix-and-suffix-search) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Hard | | 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 722 | [删除注释](../../problems/remove-comments) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -392,7 +415,7 @@ | 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 420 | [强密码检验器](../../problems/strong-password-checker) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Medium | | 415 | [字符串相加](../../problems/add-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 412 | [Fizz Buzz](../../problems/fizz-buzz) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | @@ -430,7 +453,7 @@ | 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index f3fc7304f..eddfb8658 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2127 | [参加会议的最多员工数](../../problems/maximum-employees-to-be-invited-to-a-meeting) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | diff --git a/tag/tree/README.md b/tag/tree/README.md index a4f396b09..6db216719 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,12 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/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)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | @@ -63,7 +64,7 @@ | 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -153,7 +154,7 @@ | 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -168,11 +169,11 @@ | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/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)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/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)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index b676b857d..bb35f10de 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,7 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2161 | [根据给定数字划分数组](../../problems/partition-array-according-to-given-pivot) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2149 | [按符号重排数组](../../problems/rearrange-array-elements-by-sign) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2130 | [链表最大孪生和](../../problems/maximum-twin-sum-of-a-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2108 | [找出数组中的第一个回文字符串](../../problems/find-first-palindromic-string-in-the-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 2105 | [给植物浇水 II](../../problems/watering-plants-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2095 | [删除链表的中间节点](../../problems/delete-the-middle-node-of-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2046 | [给按照绝对值排序的链表排序](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2000 | [反转单词前缀](../../problems/reverse-prefix-of-word) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | @@ -120,7 +126,7 @@ | 189 | [轮转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 165 | [比较版本号](../../problems/compare-version-numbers) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index b13c5ebf0..7ac700ad6 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2157 | [字符串分组](../../problems/groups-of-strings) | [[位运算](../bit-manipulation/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2076 | [处理含限制条件的好友请求](../../problems/process-restricted-friend-requests) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard |+ +[1-50] +[51-100] +[101-150] +[151-200] +[201-250] +[251-300] ++ +[301-350] +[351-400] +[401-450] +[451-500] +[501-550] +[551-600] ++ +[601-650] +[651-700] +[701-750] +[751-800] +[801-850] +[851-900] ++ +[901-950] +[951-1000] +[1001-1050] +[1051-1100] +[1101-1150] +[1151-1200] ++ +[1201-1250] +[1251-1300] +[1301-1350] +[1351-1400] +[1401-1450] +[1451-1500] ++ +[1501-1550] +[1551-1600] +[1601-1650] +[1651-1700] +[1701-1750] +[1751-1800] ++ +[1801-1850] +[1851-1900] +[1901-1950] +[1951-2000] +[2001-2050] +[2051-2100] ++ +[2101-2150] +[2151-2200] +[2201-2250] +[2251-2300] +[2301-2350] +[2351-2400] +