From 4ceac4287daf9a8ce9facdc79dcbccb50059a9a4 Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 6 May 2020 09:16:51 +0800 Subject: [PATCH] A: new --- README.md | 16 +++- .../README.md | 60 +++++++++++++ .../README.md | 28 ++++++ .../README.md | 66 ++++++++++++++ .../constrained-subsequence-sum/README.md | 73 +++++++++++++++ .../README.md | 10 +-- problems/counting-elements/README.md | 28 ++++++ problems/create-a-session-bar-chart/README.md | 14 +++ .../mysql_schemas.sql | 7 ++ problems/destination-city/README.md | 70 +++++++++++++++ problems/diagonal-traverse-ii/README.md | 2 +- .../README.md | 69 +++++++++++++++ problems/first-unique-number/README.md | 34 +++++++ problems/jump-game/README.md | 16 +++- .../README.md | 63 +++++++++++++ .../README.md | 28 ++++++ .../README.md | 75 ++++++++++++++++ .../README.md | 88 +++++++++++++++++++ .../README.md | 80 +++++++++++++++++ problems/ones-and-zeroes/README.md | 38 ++++---- problems/perform-string-shifts/README.md | 29 ++++++ problems/remove-boxes/README.md | 42 +++++---- problems/rotate-array/README.md | 28 ++++-- tag/array/README.md | 8 ++ tag/bit-manipulation/README.md | 1 + tag/design/README.md | 1 + tag/dynamic-programming/README.md | 3 + tag/greedy/README.md | 1 + tag/hash-table/README.md | 1 + tag/heap/README.md | 1 + tag/math/README.md | 1 + tag/sliding-window/README.md | 2 + tag/sort/README.md | 1 + tag/string/README.md | 4 + tag/tree/README.md | 1 + 35 files changed, 925 insertions(+), 64 deletions(-) create mode 100644 problems/check-if-a-string-can-break-another-string/README.md create mode 100644 problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md create mode 100644 problems/check-if-all-1s-are-at-least-length-k-places-away/README.md create mode 100644 problems/constrained-subsequence-sum/README.md create mode 100644 problems/counting-elements/README.md create mode 100644 problems/create-a-session-bar-chart/README.md create mode 100644 problems/create-a-session-bar-chart/mysql_schemas.sql create mode 100644 problems/destination-city/README.md create mode 100644 problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md create mode 100644 problems/first-unique-number/README.md create mode 100644 problems/kids-with-the-greatest-number-of-candies/README.md create mode 100644 problems/leftmost-column-with-at-least-a-one/README.md create mode 100644 problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md create mode 100644 problems/max-difference-you-can-get-from-changing-an-integer/README.md create mode 100644 problems/number-of-ways-to-wear-different-hats-to-each-other/README.md create mode 100644 problems/perform-string-shifts/README.md diff --git a/README.md b/README.md index b651a20e8..caac8d57b 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,21 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 1425 | [Constrained Subset Sum](https://leetcode.com/problems/constrained-subset-sum "带限制的子序列和") | [Go](problems/constrained-subset-sum) | Hard | +| 1439 | [Find the Kth Smallest Sum of a Matrix With Sorted Rows](https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "有序矩阵中的第 k 个最小数组和") | [Go](problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | Hard | +| 1438 | [Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit](https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "绝对差不超过限制的最长连续子数组") | [Go](problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | Medium | +| 1437 | [Check If All 1's Are at Least Length K Places Away](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素") | [Go](problems/check-if-all-1s-are-at-least-length-k-places-away) | Medium | +| 1436 | [Destination City](https://leetcode.com/problems/destination-city "旅行终点站") | [Go](problems/destination-city) | Easy | +| 1435 | [Create a Session Bar Chart](https://leetcode.com/problems/create-a-session-bar-chart) 🔒 | [MySQL](problems/create-a-session-bar-chart) | Easy | +| 1434 | [Number of Ways to Wear Different Hats to Each Other](https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other "每个人戴不同帽子的方案数") | [Go](problems/number-of-ways-to-wear-different-hats-to-each-other) | Hard | +| 1433 | [Check If a String Can Break Another String](https://leetcode.com/problems/check-if-a-string-can-break-another-string "检查一个字符串是否可以打破另一个字符串") | [Go](problems/check-if-a-string-can-break-another-string) | Medium | +| 1432 | [Max Difference You Can Get From Changing an Integer](https://leetcode.com/problems/max-difference-you-can-get-from-changing-an-integer "改变一个整数能得到的最大差值") | [Go](problems/max-difference-you-can-get-from-changing-an-integer) | Medium | +| 1431 | [Kids With the Greatest Number of Candies](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies "拥有最多糖果的孩子") | [Go](problems/kids-with-the-greatest-number-of-candies) | Easy | +| 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [Go](problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) | Medium | +| 1429 | [First Unique Number](https://leetcode.com/problems/first-unique-number) 🔒 | [Go](problems/first-unique-number) | Medium | +| 1428 | [Leftmost Column with at Least a One](https://leetcode.com/problems/leftmost-column-with-at-least-a-one) 🔒 | [Go](problems/leftmost-column-with-at-least-a-one) | Medium | +| 1427 | [Perform String Shifts](https://leetcode.com/problems/perform-string-shifts) 🔒 | [Go](problems/perform-string-shifts) | Easy | +| 1426 | [Counting Elements](https://leetcode.com/problems/counting-elements "数元素") 🔒 | [Go](problems/counting-elements) | Easy | +| 1425 | [Constrained Subsequence Sum](https://leetcode.com/problems/constrained-subsequence-sum "带限制的子序列和") | [Go](problems/constrained-subsequence-sum) | Hard | | 1424 | [Diagonal Traverse II](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") | [Go](problems/diagonal-traverse-ii) | Medium | | 1423 | [Maximum Points You Can Obtain from Cards](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards "可获得的最大点数") | [Go](problems/maximum-points-you-can-obtain-from-cards) | Medium | | 1422 | [Maximum Score After Splitting a String](https://leetcode.com/problems/maximum-score-after-splitting-a-string "分割字符串的最大得分") | [Go](problems/maximum-score-after-splitting-a-string) | Easy | diff --git a/problems/check-if-a-string-can-break-another-string/README.md b/problems/check-if-a-string-can-break-another-string/README.md new file mode 100644 index 000000000..8216e3e01 --- /dev/null +++ b/problems/check-if-a-string-can-break-another-string/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../max-difference-you-can-get-from-changing-an-integer "Max Difference You Can Get From Changing an Integer") +                 +[Next >](../number-of-ways-to-wear-different-hats-to-each-other "Number of Ways to Wear Different Hats to Each Other") + +## [1433. Check If a String Can Break Another String (Medium)](https://leetcode.com/problems/check-if-a-string-can-break-another-string "检查一个字符串是否可以打破另一个字符串") + +

Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).

+ +

A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.

+ +

 

+

Example 1:

+ +
+Input: s1 = "abc", s2 = "xya"
+Output: true
+Explanation: "ayx" is a permutation of s2="xya" which can break to string "abc" which is a permutation of s1="abc".
+
+ +

Example 2:

+ +
+Input: s1 = "abe", s2 = "acd"
+Output: false 
+Explanation: All permutations for s1="abe" are: "abe", "aeb", "bae", "bea", "eab" and "eba" and all permutation for s2="acd" are: "acd", "adc", "cad", "cda", "dac" and "dca". However, there is not any permutation from s1 which can break some permutation from s2 and vice-versa.
+
+ +

Example 3:

+ +
+Input: s1 = "leetcodee", s2 = "interview"
+Output: true
+
+ +

 

+

Constraints:

+ + + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +Sort both strings and then check if one of them can break the other. +
diff --git a/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md b/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md new file mode 100644 index 000000000..324291e90 --- /dev/null +++ b/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../first-unique-number "First Unique Number") +                 +[Next >](../kids-with-the-greatest-number-of-candies "Kids With the Greatest Number of Candies") + +## [1430. Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree (Medium)](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + +### Hints +
+Hint 1 +Depth-first search (DFS) with the parameters: current node in the binary tree and current position in the array of integers. +
+ +
+Hint 2 +When reaching at final position check if it is a leaf node. +
diff --git a/problems/check-if-all-1s-are-at-least-length-k-places-away/README.md b/problems/check-if-all-1s-are-at-least-length-k-places-away/README.md new file mode 100644 index 000000000..b285ea86e --- /dev/null +++ b/problems/check-if-all-1s-are-at-least-length-k-places-away/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../destination-city "Destination City") +                 +[Next >](../longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit") + +## [1437. Check If All 1's Are at Least Length K Places Away (Medium)](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素") + +

Given an array nums of 0s and 1s and an integer k, return True if all 1's are at least k places away from each other, otherwise return False.

+ +

 

+

Example 1:

+ +

+ +
+Input: nums = [1,0,0,0,1,0,0,1], k = 2
+Output: true
+Explanation: Each of the 1s are at least 2 places away from each other.
+
+ +

Example 2:

+ +

+ +
+Input: nums = [1,0,0,1,0,1], k = 2
+Output: false
+Explanation: The second 1 and third 1 are only one apart from each other.
+ +

Example 3:

+ +
+Input: nums = [1,1,1,1,1], k = 0
+Output: true
+
+ +

Example 4:

+ +
+Input: nums = [0,1,0,1], k = 1
+Output: true
+
+ +

 

+

Constraints:

+ + + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +Each time you find a number 1, check whether or not it is K or more places away from the next one. If it's not, return false. +
diff --git a/problems/constrained-subsequence-sum/README.md b/problems/constrained-subsequence-sum/README.md new file mode 100644 index 000000000..7c76eaa23 --- /dev/null +++ b/problems/constrained-subsequence-sum/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../diagonal-traverse-ii "Diagonal Traverse II") +                 +[Next >](../counting-elements "Counting Elements") + +## [1425. Constrained Subsequence Sum (Hard)](https://leetcode.com/problems/constrained-subsequence-sum "带限制的子序列和") + +

Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied.

+ +

subsequence of an array is obtained by deleting some number of elements (can be zero) from the array, leaving the remaining elements in their original order.

+ +

 

+

Example 1:

+ +
+Input: nums = [10,2,-10,5,20], k = 2
+Output: 37
+Explanation: The subsequence is [10, 2, 5, 20].
+
+ +

Example 2:

+ +
+Input: nums = [-1,-2,-3], k = 1
+Output: -1
+Explanation: The subsequence must be non-empty, so we choose the largest number.
+
+ +

Example 3:

+ +
+Input: nums = [10,-2,-10,-5,20], k = 2
+Output: 23
+Explanation: The subsequence is [10, -2, -5, 20].
+
+ +

 

+

Constraints:

+ + + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +Use dynamic programming. +
+ +
+Hint 2 +Let dp[i] be the solution for the prefix of the array that ends at index i, if the element at index i is in the subsequence. +
+ +
+Hint 3 +dp[i] = nums[i] + max(0, dp[i-k], dp[i-k+1], ..., dp[i-1]) +
+ +
+Hint 4 +Use a heap with the sliding window technique to optimize the dp. +
diff --git a/problems/construct-binary-search-tree-from-preorder-traversal/README.md b/problems/construct-binary-search-tree-from-preorder-traversal/README.md index 982740fb7..f0f85cc8b 100644 --- a/problems/construct-binary-search-tree-from-preorder-traversal/README.md +++ b/problems/construct-binary-search-tree-from-preorder-traversal/README.md @@ -15,7 +15,7 @@

(Recall that a binary search tree is a binary tree where for every node, any descendant of node.left has a value < node.val, and any descendant of node.right has a value > node.val.  Also recall that a preorder traversal displays the value of the node first, then traverses node.left, then traverses node.right.)

-

 

+

It's guaranteed that for the given test cases there is always possible to find a binary search tree with the given requirements.

Example 1:

@@ -26,13 +26,13 @@

 

+

Constraints:

-

Note: 

- -
    +
+ ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/counting-elements/README.md b/problems/counting-elements/README.md new file mode 100644 index 000000000..ee43f6c68 --- /dev/null +++ b/problems/counting-elements/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../constrained-subsequence-sum "Constrained Subsequence Sum") +                 +[Next >](../perform-string-shifts "Perform String Shifts") + +## [1426. Counting Elements (Easy)](https://leetcode.com/problems/counting-elements "数元素") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +Use hashset to store all elements. +
+ +
+Hint 2 +Loop again to count all valid elements. +
diff --git a/problems/create-a-session-bar-chart/README.md b/problems/create-a-session-bar-chart/README.md new file mode 100644 index 000000000..5f135a792 --- /dev/null +++ b/problems/create-a-session-bar-chart/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../number-of-ways-to-wear-different-hats-to-each-other "Number of Ways to Wear Different Hats to Each Other") +                 +[Next >](../destination-city "Destination City") + +## [1435. Create a Session Bar Chart (Easy)](https://leetcode.com/problems/create-a-session-bar-chart "") + + diff --git a/problems/create-a-session-bar-chart/mysql_schemas.sql b/problems/create-a-session-bar-chart/mysql_schemas.sql new file mode 100644 index 000000000..6041cffa5 --- /dev/null +++ b/problems/create-a-session-bar-chart/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Sessions (session_id int, duration int); +Truncate table Sessions; +insert into Sessions (session_id, duration) values ('1', '30'); +insert into Sessions (session_id, duration) values ('2', '199'); +insert into Sessions (session_id, duration) values ('3', '299'); +insert into Sessions (session_id, duration) values ('4', '580'); +insert into Sessions (session_id, duration) values ('5', '1000'); diff --git a/problems/destination-city/README.md b/problems/destination-city/README.md new file mode 100644 index 000000000..76d0c3b81 --- /dev/null +++ b/problems/destination-city/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../create-a-session-bar-chart "Create a Session Bar Chart") +                 +[Next >](../check-if-all-1s-are-at-least-length-k-places-away "Check If All 1's Are at Least Length K Places Away") + +## [1436. Destination City (Easy)](https://leetcode.com/problems/destination-city "旅行终点站") + +

You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any path outgoing to another city.

+ +

It is guaranteed that the graph of paths forms a line without any loop, therefore, there will be exactly one destination city.

+ +

 

+

Example 1:

+ +
+Input: paths = [["London","New York"],["New York","Lima"],["Lima","Sao Paulo"]]
+Output: "Sao Paulo" 
+Explanation: Starting at "London" city you will reach "Sao Paulo" city which is the destination city. Your trip consist of: "London" -> "New York" -> "Lima" -> "Sao Paulo".
+
+ +

Example 2:

+ +
+Input: paths = [["B","C"],["D","B"],["C","A"]]
+Output: "A"
+Explanation: All possible trips are: 
+"D" -> "B" -> "C" -> "A". 
+"B" -> "C" -> "A". 
+"C" -> "A". 
+"A". 
+Clearly the destination city is "A".
+
+ +

Example 3:

+ +
+Input: paths = [["A","Z"]]
+Output: "Z"
+
+ +

 

+

Constraints:

+ + + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +Start in any city and use the path to move to the next city. +
+ +
+Hint 2 +Eventually, you will reach a city with no path outgoing, this is the destination city. +
diff --git a/problems/diagonal-traverse-ii/README.md b/problems/diagonal-traverse-ii/README.md index d856f64d7..74b730804 100644 --- a/problems/diagonal-traverse-ii/README.md +++ b/problems/diagonal-traverse-ii/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-points-you-can-obtain-from-cards "Maximum Points You Can Obtain from Cards")                  -[Next >](../constrained-subset-sum "Constrained Subset Sum") +[Next >](../constrained-subsequence-sum "Constrained Subsequence Sum") ## [1424. Diagonal Traverse II (Medium)](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") 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 new file mode 100644 index 000000000..a821a5a06 --- /dev/null +++ b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< 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") +                 +Next > + +## [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 * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing order.

+ +

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.

+ +

 

+

Example 1:

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

Example 2:

+ +
+Input: mat = [[1,3,11],[2,4,6]], k = 9
+Output: 17
+
+ +

Example 3:

+ +
+Input: mat = [[1,10,10],[1,4,5],[2,3,6]], k = 7
+Output: 9
+Explanation: Choosing one element from each row, the first k smallest sum are:
+[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:

+ + + +### Related Topics + [[Heap](../../tag/heap/README.md)] + +### Hints +
+Hint 1 +Save all visited sums and corresponding indexes in a priority queue. Then, once you pop the smallest sum so far, you can quickly identify the next m candidates for smallest sum by incrementing each row index by 1. +
diff --git a/problems/first-unique-number/README.md b/problems/first-unique-number/README.md new file mode 100644 index 000000000..e41636f56 --- /dev/null +++ b/problems/first-unique-number/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](../leftmost-column-with-at-least-a-one "Leftmost Column with at Least a One") +                 +[Next >](../check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree") + +## [1429. First Unique Number (Medium)](https://leetcode.com/problems/first-unique-number "") + + + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
+Hint 1 +Use doubly Linked list with hashmap of pointers to linked list nodes. add unique number to the linked list. When add is called check if the added number is unique then it have to be added to the linked list and if it is repeated remove it from the linked list if exists. When showFirstUnique is called retrieve the head of the linked list. +
+ +
+Hint 2 +Use queue and check that first element of the queue is always unique. +
+ +
+Hint 3 +Use set or heap to make running time of each function O(logn). +
diff --git a/problems/jump-game/README.md b/problems/jump-game/README.md index 73f8105a1..566f54531 100644 --- a/problems/jump-game/README.md +++ b/problems/jump-game/README.md @@ -17,10 +17,11 @@

Determine if you are able to reach the last index.

+

 

Example 1:

-Input: [2,3,1,1,4]
+Input: nums = [2,3,1,1,4]
 Output: true
 Explanation: Jump 1 step from index 0 to 1, then 3 steps to the last index.
 
@@ -28,12 +29,19 @@

Example 2:

-Input: [3,2,1,0,4]
+Input: nums = [3,2,1,0,4]
 Output: false
-Explanation: You will always arrive at index 3 no matter what. Its maximum
-             jump length is 0, which makes it impossible to reach the last index.
+Explanation: You will always arrive at index 3 no matter what. Its maximum jump length is 0, which makes it impossible to reach the last index.
 
+

 

+

Constraints:

+ + + ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/kids-with-the-greatest-number-of-candies/README.md b/problems/kids-with-the-greatest-number-of-candies/README.md new file mode 100644 index 000000000..df7073b98 --- /dev/null +++ b/problems/kids-with-the-greatest-number-of-candies/README.md @@ -0,0 +1,63 @@ + + + + + + + +[< Previous](../check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree") +                 +[Next >](../max-difference-you-can-get-from-changing-an-integer "Max Difference You Can Get From Changing an Integer") + +## [1431. Kids With the Greatest Number of Candies (Easy)](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies "拥有最多糖果的孩子") + +

Given the array candies and the integer extraCandies, where candies[i] represents the number of candies that the ith kid has.

+ +

For each kid check if there is a way to distribute extraCandies among the kids such that he or she can have the greatest number of candies among them. Notice that multiple kids can have the greatest number of candies.

+ +

 

+

Example 1:

+ +
+Input: candies = [2,3,5,1,3], extraCandies = 3
+Output: [true,true,true,false,true] 
+Explanation: 
+Kid 1 has 2 candies and if he or she receives all extra candies (3) will have 5 candies --- the greatest number of candies among the kids. 
+Kid 2 has 3 candies and if he or she receives at least 2 extra candies will have the greatest number of candies among the kids. 
+Kid 3 has 5 candies and this is already the greatest number of candies among the kids. 
+Kid 4 has 1 candy and even if he or she receives all extra candies will only have 4 candies. 
+Kid 5 has 3 candies and if he or she receives at least 2 extra candies will have the greatest number of candies among the kids. 
+
+ +

Example 2:

+ +
+Input: candies = [4,2,1,1,2], extraCandies = 1
+Output: [true,false,false,false,false] 
+Explanation: There is only 1 extra candy, therefore only kid 1 will have the greatest number of candies among the kids regardless of who takes the extra candy.
+
+ +

Example 3:

+ +
+Input: candies = [12,1,12], extraCandies = 10
+Output: [true,false,true]
+
+ +

 

+

Constraints:

+ + + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +Use greedy approach. For each kid check if candies[i] + extraCandies ≥ maximum in Candies[i]. +
diff --git a/problems/leftmost-column-with-at-least-a-one/README.md b/problems/leftmost-column-with-at-least-a-one/README.md new file mode 100644 index 000000000..bcf077e40 --- /dev/null +++ b/problems/leftmost-column-with-at-least-a-one/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../perform-string-shifts "Perform String Shifts") +                 +[Next >](../first-unique-number "First Unique Number") + +## [1428. Leftmost Column with at Least a One (Medium)](https://leetcode.com/problems/leftmost-column-with-at-least-a-one "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +1. (Binary Search) For each row do a binary search to find the leftmost one on that row and update the answer. +
+ +
+Hint 2 +2. (Optimal Approach) Imagine there is a pointer p(x, y) starting from top right corner. p can only move left or down. If the value at p is 0, move down. If the value at p is 1, move left. Try to figure out the correctness and time complexity of this algorithm. +
diff --git a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md new file mode 100644 index 000000000..a2239cd27 --- /dev/null +++ b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../check-if-all-1s-are-at-least-length-k-places-away "Check If All 1's Are at Least Length K Places Away") +                 +[Next >](../find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "Find the Kth Smallest Sum of a Matrix With Sorted Rows") + +## [1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit (Medium)](https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "绝对差不超过限制的最长连续子数组") + +

Given an array of integers nums and an integer limit, return the size of the longest continuous subarray such that the absolute difference between any two elements is less than or equal to limit.

+ +

In case there is no subarray satisfying the given condition return 0.

+ +

 

+

Example 1:

+ +
+Input: nums = [8,2,4,7], limit = 4
+Output: 2 
+Explanation: All subarrays are: 
+[8] with maximum absolute diff |8-8| = 0 <= 4.
+[8,2] with maximum absolute diff |8-2| = 6 > 4. 
+[8,2,4] with maximum absolute diff |8-2| = 6 > 4.
+[8,2,4,7] with maximum absolute diff |8-2| = 6 > 4.
+[2] with maximum absolute diff |2-2| = 0 <= 4.
+[2,4] with maximum absolute diff |2-4| = 2 <= 4.
+[2,4,7] with maximum absolute diff |2-7| = 5 > 4.
+[4] with maximum absolute diff |4-4| = 0 <= 4.
+[4,7] with maximum absolute diff |4-7| = 3 <= 4.
+[7] with maximum absolute diff |7-7| = 0 <= 4. 
+Therefore, the size of the longest subarray is 2.
+
+ +

Example 2:

+ +
+Input: nums = [10,1,2,4,7,2], limit = 5
+Output: 4 
+Explanation: The subarray [2,4,7,2] is the longest since the maximum absolute diff is |2-7| = 5 <= 5.
+
+ +

Example 3:

+ +
+Input: nums = [4,2,2,2,4,4,2,2], limit = 0
+Output: 3
+
+ +

 

+

Constraints:

+ + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
+Hint 1 +Use a sliding window approach keeping the maximum and minimum value using a data structure like a multiset from STL in C++. +
+ +
+Hint 2 +More specifically, use the two pointer technique, moving the right pointer as far as possible to the right until the subarray is not valid (maxValue - minValue > limit), then moving the left pointer until the subarray is valid again (maxValue - minValue <= limit). Keep repeating this process. +
diff --git a/problems/max-difference-you-can-get-from-changing-an-integer/README.md b/problems/max-difference-you-can-get-from-changing-an-integer/README.md new file mode 100644 index 000000000..3c1901b55 --- /dev/null +++ b/problems/max-difference-you-can-get-from-changing-an-integer/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../kids-with-the-greatest-number-of-candies "Kids With the Greatest Number of Candies") +                 +[Next >](../check-if-a-string-can-break-another-string "Check If a String Can Break Another String") + +## [1432. Max Difference You Can Get From Changing an Integer (Medium)](https://leetcode.com/problems/max-difference-you-can-get-from-changing-an-integer "改变一个整数能得到的最大差值") + +

You are given an integer num. You will apply the following steps exactly two times:

+ + + +

Let a and b be the results of applying the operations to num the first and second times, respectively.

+ +

Return the max difference between a and b.

+ +

 

+

Example 1:

+ +
+Input: num = 555
+Output: 888
+Explanation: The first time pick x = 5 and y = 9 and store the new integer in a.
+The second time pick x = 5 and y = 1 and store the new integer in b.
+We have now a = 999 and b = 111 and max difference = 888
+
+ +

Example 2:

+ +
+Input: num = 9
+Output: 8
+Explanation: The first time pick x = 9 and y = 9 and store the new integer in a.
+The second time pick x = 9 and y = 1 and store the new integer in b.
+We have now a = 9 and b = 1 and max difference = 8
+
+ +

Example 3:

+ +
+Input: num = 123456
+Output: 820000
+
+ +

Example 4:

+ +
+Input: num = 10000
+Output: 80000
+
+ +

Example 5:

+ +
+Input: num = 9288
+Output: 8700
+
+ +

 

+

Constraints:

+ + + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +We need to get the max and min value after changing num and the answer is max - min. +
+ +
+Hint 2 +Use brute force, try all possible changes and keep the minimum and maximum values. +
diff --git a/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md new file mode 100644 index 000000000..802f61ba6 --- /dev/null +++ b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../check-if-a-string-can-break-another-string "Check If a String Can Break Another String") +                 +[Next >](../create-a-session-bar-chart "Create a Session Bar Chart") + +## [1434. Number of Ways to Wear Different Hats to Each Other (Hard)](https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other "每个人戴不同帽子的方案数") + +

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.

+ +

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.

+ +

 

+

Example 1:

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

Example 2:

+ +
+Input: hats = [[3,5,1],[3,5]]
+Output: 4
+Explanation: There are 4 ways to choose hats
+(3,5), (5,3), (1,3) and (1,5)
+
+ +

Example 3:

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

+ + + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +Dynamic programming + bitmask. +
+ +
+Hint 2 +dp(peopleMask, idHat) number of ways to wear different hats given a bitmask (people visited) and used hats from 1 to idHat-1. +
diff --git a/problems/ones-and-zeroes/README.md b/problems/ones-and-zeroes/README.md index dbbe1cc58..de0279e7a 100644 --- a/problems/ones-and-zeroes/README.md +++ b/problems/ones-and-zeroes/README.md @@ -11,42 +11,36 @@ ## [474. Ones and Zeroes (Medium)](https://leetcode.com/problems/ones-and-zeroes "一和零") -

In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue.

- -

For now, suppose you are a dominator of m 0s and n 1s respectively. On the other hand, there is an array with strings consisting of only 0s and 1s.

+

Given an array, strs, with strings consisting of only 0s and 1s. Also two integers m and n.

Now your task is to find the maximum number of strings that you can form with given m 0s and n 1s. Each 0 and 1 can be used at most once.

-

Note:

- -
    -
  1. The given numbers of 0s and 1s will both not exceed 100
  2. -
  3. The size of given string array won't exceed 600.
  4. -
-

 

- -

Example 1:

+

Example 1:

-Input: Array = {"10", "0001", "111001", "1", "0"}, m = 5, n = 3
-Output: 4
-
-Explanation: This are totally 4 strings can be formed by the using of 5 0s and 3 1s, which are “10,”0001”,”1”,”0”
+Input: strs = ["10","0001","111001","1","0"], m = 5, n = 3
+Output: 4
+Explanation: This are totally 4 strings can be formed by the using of 5 0s and 3 1s, which are "10","0001","1","0".
 
-

 

- -

Example 2:

+

Example 2:

-Input: Array = {"10", "0", "1"}, m = 1, n = 1
-Output: 2
-
+Input: strs = ["10","0","1"], m = 1, n = 1
+Output: 2
 Explanation: You could form "10", but then you'd have nothing left. Better form "0" and "1".
 

 

+

Constraints:

+ + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/perform-string-shifts/README.md b/problems/perform-string-shifts/README.md new file mode 100644 index 000000000..3c25d222a --- /dev/null +++ b/problems/perform-string-shifts/README.md @@ -0,0 +1,29 @@ + + + + + + + +[< Previous](../counting-elements "Counting Elements") +                 +[Next >](../leftmost-column-with-at-least-a-one "Leftmost Column with at Least a One") + +## [1427. Perform String Shifts (Easy)](https://leetcode.com/problems/perform-string-shifts "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
+Hint 1 +Intuitively performing all shift operations is acceptable due to the constraints. +
+ +
+Hint 2 +You may notice that left shift cancels the right shift, so count the total left shift times (may be negative if the final result is right shift), and perform it once. +
diff --git a/problems/remove-boxes/README.md b/problems/remove-boxes/README.md index ff1ac85fb..553648a4d 100644 --- a/problems/remove-boxes/README.md +++ b/problems/remove-boxes/README.md @@ -11,33 +11,31 @@ ## [546. Remove Boxes (Hard)](https://leetcode.com/problems/remove-boxes "移除盒子") -

Given several boxes with different colors represented by different positive numbers.
-You may experience several rounds to remove boxes until there is no box left. Each time you can choose some continuous boxes with the same color (composed of k boxes, k >= 1), remove them and get k*k points.
-Find the maximum points you can get. -

+

Given several boxes with different colors represented by different positive numbers.
+You may experience several rounds to remove boxes until there is no box left. Each time you can choose some continuous boxes with the same color (composed of k boxes, k >= 1), remove them and get k*k points.
+Find the maximum points you can get.

+ +

 

+

Example 1:

-

Example 1:
-Input: -

-[1, 3, 2, 2, 2, 3, 4, 3, 1]
-
-Output: -
-23
-
-Explanation:
+Input: boxes = [1,3,2,2,2,3,4,3,1]
+Output: 23
+Explanation:
 [1, 3, 2, 2, 2, 3, 4, 3, 1] 
-----> [1, 3, 3, 4, 3, 1] (3*3=9 points) 
-----> [1, 3, 3, 3, 1] (1*1=1 points) 
-----> [1, 1] (3*3=9 points) 
-----> [] (2*2=4 points)
+----> [1, 3, 3, 4, 3, 1] (3*3=9 points) 
+----> [1, 3, 3, 3, 1] (1*1=1 points) 
+----> [1, 1] (3*3=9 points) 
+----> [] (2*2=4 points)
 
-

-

Note: -The number of boxes n would not exceed 100. -

+

 

+

Constraints:

+ + ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/rotate-array/README.md b/problems/rotate-array/README.md index 0492b89a0..af79af5b7 100644 --- a/problems/rotate-array/README.md +++ b/problems/rotate-array/README.md @@ -13,32 +13,42 @@

Given an array, rotate the array to the right by k steps, where k is non-negative.

+

Follow up:

+ + + +

 

Example 1:

-Input: [1,2,3,4,5,6,7] and k = 3
-Output: [5,6,7,1,2,3,4]
+Input: nums = [1,2,3,4,5,6,7], k = 3
+Output: [5,6,7,1,2,3,4]
 Explanation:
-rotate 1 steps to the right: [7,1,2,3,4,5,6]
-rotate 2 steps to the right: [6,7,1,2,3,4,5]
-rotate 3 steps to the right: [5,6,7,1,2,3,4]
+rotate 1 steps to the right: [7,1,2,3,4,5,6]
+rotate 2 steps to the right: [6,7,1,2,3,4,5]
+rotate 3 steps to the right: [5,6,7,1,2,3,4]
 

Example 2:

-Input: [-1,-100,3,99] and k = 2
+Input: nums = [-1,-100,3,99], k = 2
 Output: [3,99,-1,-100]
 Explanation: 
 rotate 1 steps to the right: [99,-1,-100,3]
 rotate 2 steps to the right: [3,99,-1,-100]
 
-

Note:

+

 

+

Constraints:

### Related Topics diff --git a/tag/array/README.md b/tag/array/README.md index 9c3a0f06e..78bfe62c8 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,14 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1437 | [是否所有 1 都至少相隔 k 个元素](../../problems/check-if-all-1s-are-at-least-length-k-places-away) | [[数组](../array/README.md)] | Medium | +| 1431 | [拥有最多糖果的孩子](../../problems/kids-with-the-greatest-number-of-candies) | [[数组](../array/README.md)] | Easy | +| 1428 | [Leftmost Column with at Least a One](../../problems/leftmost-column-with-at-least-a-one) 🔒 | [[数组](../array/README.md)] | Medium | +| 1427 | [Perform String Shifts](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1426 | [数元素](../../problems/counting-elements) 🔒 | [[数组](../array/README.md)] | Easy | +| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1413 | [逐步求和得到正数的最小值](../../problems/minimum-value-to-get-positive-step-by-step-sum) | [[数组](../array/README.md)] | Easy | | 1409 | [查询带键的排列](../../problems/queries-on-a-permutation-with-key) | [[数组](../array/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 666decd3d..f3b48ab7c 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | | 1342 | [将数字变成 0 的操作次数](../../problems/number-of-steps-to-reduce-a-number-to-zero) | [[位运算](../bit-manipulation/README.md)] | Easy | diff --git a/tag/design/README.md b/tag/design/README.md index 0f442f13a..546da5322 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1429 | [First Unique Number](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index a0fd30ca1..322c4233d 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1420 | [生成数组](../../problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1416 | [恢复数组](../../problems/restore-the-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1411 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-x-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 548d29949..8be0add8c 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 2a1714f20..7065347c2 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1429 | [First Unique Number](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[哈希表](../hash-table/README.md)] | Medium | | 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index 4c04d66bd..b815bcaee 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1439 | [有序矩阵中的第 k 个最小数组和](../../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | [[堆](../heap/README.md)] | Hard | | 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | | 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | | 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index ada7dc38e..9d25bf985 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1427 | [Perform String Shifts](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1390 | [四因数](../../problems/four-divisors) | [[数学](../math/README.md)] | Medium | | 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1362 | [最接近的因数](../../problems/closest-divisors) | [[数学](../math/README.md)] | Medium | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index dc035894e..5ad662cb4 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | | 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 5b346163f..bc64cd5ac 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | | 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | | 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | diff --git a/tag/string/README.md b/tag/string/README.md index 4e53dd7eb..50dcda9dc 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1436 | [旅行终点站](../../problems/destination-city) | [[字符串](../string/README.md)] | Easy | +| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[字符串](../string/README.md)] | Medium | +| 1422 | [分割字符串的最大得分](../../problems/maximum-score-after-splitting-a-string) | [[字符串](../string/README.md)] | Easy | | 1419 | [数青蛙](../../problems/minimum-number-of-frogs-croaking) | [[字符串](../string/README.md)] | Medium | | 1417 | [重新格式化字符串](../../problems/reformat-the-string) | [[字符串](../string/README.md)] | Easy | | 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index af1c23a9e..537be7ad1 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | | 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] | Medium | | 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium |