From d50023a6c0923854838ada06ceb1196c4f454fe3 Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 6 Apr 2021 11:32:05 +0800 Subject: [PATCH 1/2] A: new --- README.md | 16 +++ problems/132-pattern/README.md | 2 +- problems/3sum/README.md | 2 +- problems/ad-free-sessions/README.md | 14 +++ problems/ad-free-sessions/mysql_schemas.sql | 12 +++ problems/add-strings/README.md | 45 +++++++-- .../add-to-array-form-of-integer/README.md | 61 +++++------- problems/candy/README.md | 2 +- problems/combinations/README.md | 2 +- problems/continuous-subarray-sum/README.md | 33 ++++--- .../count-nice-pairs-in-an-array/README.md | 67 +++++++++++++ .../README.md | 22 +++-- .../count-pairs-with-xor-in-a-range/README.md | 2 +- .../README.md | 45 +++++++-- problems/design-twitter/README.md | 67 +++++++------ problems/design-underground-system/README.md | 51 +++++----- .../README.md | 67 +++++++++++++ problems/di-string-match/README.md | 52 ++++------ problems/distinct-subsequences/README.md | 2 +- problems/divisor-game/README.md | 33 +++---- problems/elimination-game/README.md | 46 ++++++--- .../README.md | 97 +++++++++++++++++++ .../README.md | 32 +++--- .../find-duplicate-file-in-system/README.md | 57 +++++------ problems/find-interview-candidates/README.md | 14 +++ .../mysql_schemas.sql | 16 +++ .../find-k-pairs-with-smallest-sums/README.md | 39 +++++--- .../README.md | 70 +++++++++++++ .../README.md | 27 +++--- .../flatten-nested-list-iterator/README.md | 38 +++++--- problems/guess-the-word/README.md | 47 ++++++--- .../implement-trie-ii-prefix-tree/README.md | 34 +++++++ problems/implement-trie-prefix-tree/README.md | 14 +-- problems/interleaving-string/README.md | 7 +- problems/k-closest-points-to-origin/README.md | 4 +- .../README.md | 2 +- problems/kth-smallest-instructions/README.md | 5 +- problems/lexicographical-numbers/README.md | 20 +++- .../README.md | 24 +++-- problems/matrix-block-sum/README.md | 15 ++- .../README.md | 3 +- .../README.md | 72 ++++++++++++++ .../README.md | 67 +++++++++++++ problems/maximum-product-subarray/README.md | 1 + .../README.md | 7 +- problems/mini-parser/README.md | 41 ++++---- .../minimum-absolute-sum-difference/README.md | 82 ++++++++++++++++ .../README.md | 14 +-- .../README.md | 77 +++++++++++++++ .../README.md | 35 +++++++ problems/next-greater-element-ii/README.md | 36 ++++--- .../README.md | 67 +++++++++++++ .../README.md | 77 +++++++++++++++ .../pacific-atlantic-water-flow/README.md | 44 ++++----- problems/path-with-maximum-gold/README.md | 16 +-- problems/perfect-rectangle/README.md | 93 ++++++------------ problems/powx-n/README.md | 2 +- problems/random-pick-index/README.md | 40 +++++--- .../README.md | 41 ++++---- .../README.md | 2 +- problems/reordered-power-of-2/README.md | 47 +++------ problems/reverse-vowels-of-a-string/README.md | 32 +++--- problems/rotate-array/README.md | 17 ++-- problems/rotate-function/README.md | 45 +++++---- problems/russian-doll-envelopes/README.md | 4 +- problems/sentence-similarity-iii/README.md | 73 ++++++++++++++ problems/truncate-sentence/README.md | 74 ++++++++++++++ problems/tweet-counts-per-frequency/README.md | 44 +++++---- problems/utf-8-validation/README.md | 63 ++++++------ problems/vowel-spellchecker/README.md | 29 +++--- problems/water-and-jug-problem/README.md | 34 ++++--- problems/wiggle-subsequence/README.md | 17 ++-- problems/word-search/README.md | 5 +- readme/1-300.md | 4 +- readme/301-600.md | 2 +- tag/README.md | 6 +- tag/array/README.md | 4 +- tag/binary-search/README.md | 1 + tag/depth-first-search/README.md | 1 + tag/design/README.md | 61 ------------ tag/dynamic-programming/README.md | 3 +- tag/graph/README.md | 1 + tag/greedy/README.md | 2 + tag/hash-table/README.md | 3 + tag/heap/README.md | 43 -------- tag/math/README.md | 2 + tag/memoization/README.md | 1 - tag/ordered-map/README.md | 14 --- tag/queue/README.md | 11 --- tag/recursion/README.md | 39 -------- tag/segment-tree/README.md | 16 --- tag/sliding-window/README.md | 27 ------ tag/stack/README.md | 2 +- tag/string/README.md | 8 +- tag/tags.json | 20 ++-- tag/trie/README.md | 1 + tag/two-pointers/README.md | 74 -------------- 97 files changed, 1872 insertions(+), 980 deletions(-) create mode 100644 problems/ad-free-sessions/README.md create mode 100644 problems/ad-free-sessions/mysql_schemas.sql create mode 100644 problems/count-nice-pairs-in-an-array/README.md create mode 100644 problems/determine-color-of-a-chessboard-square/README.md create mode 100644 problems/evaluate-the-bracket-pairs-of-a-string/README.md create mode 100644 problems/find-interview-candidates/README.md create mode 100644 problems/find-interview-candidates/mysql_schemas.sql create mode 100644 problems/finding-the-users-active-minutes/README.md create mode 100644 problems/implement-trie-ii-prefix-tree/README.md create mode 100644 problems/maximize-number-of-nice-divisors/README.md create mode 100644 problems/maximum-number-of-groups-getting-fresh-donuts/README.md create mode 100644 problems/minimum-absolute-sum-difference/README.md create mode 100644 problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md create mode 100644 problems/minimum-path-cost-in-a-hidden-grid/README.md create mode 100644 problems/number-of-different-integers-in-a-string/README.md create mode 100644 problems/number-of-different-subsequences-gcds/README.md create mode 100644 problems/sentence-similarity-iii/README.md create mode 100644 problems/truncate-sentence/README.md diff --git a/README.md b/README.md index e8fc2478e..8808bc253 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,22 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1819 | [Number of Different Subsequences GCDs](https://leetcode.com/problems/number-of-different-subsequences-gcds "序列中不同最大公约数的数目") | [Go](problems/number-of-different-subsequences-gcds) | Hard | +| 1818 | [Minimum Absolute Sum Difference](https://leetcode.com/problems/minimum-absolute-sum-difference "绝对差值和") | [Go](problems/minimum-absolute-sum-difference) | Medium | +| 1817 | [Finding the Users Active Minutes](https://leetcode.com/problems/finding-the-users-active-minutes "查找用户活跃分钟数") | [Go](problems/finding-the-users-active-minutes) | Medium | +| 1816 | [Truncate Sentence](https://leetcode.com/problems/truncate-sentence "截断句子") | [Go](problems/truncate-sentence) | Easy | +| 1815 | [Maximum Number of Groups Getting Fresh Donuts](https://leetcode.com/problems/maximum-number-of-groups-getting-fresh-donuts "得到新鲜甜甜圈的最多组数") | [Go](problems/maximum-number-of-groups-getting-fresh-donuts) | Hard | +| 1814 | [Count Nice Pairs in an Array](https://leetcode.com/problems/count-nice-pairs-in-an-array "统计一个数组中好对子的数目") | [Go](problems/count-nice-pairs-in-an-array) | Medium | +| 1813 | [Sentence Similarity III](https://leetcode.com/problems/sentence-similarity-iii "句子相似性 III") | [Go](problems/sentence-similarity-iii) | Medium | +| 1812 | [Determine Color of a Chessboard Square](https://leetcode.com/problems/determine-color-of-a-chessboard-square "判断国际象棋棋盘中一个格子的颜色") | [Go](problems/determine-color-of-a-chessboard-square) | Easy | +| 1811 | [Find Interview Candidates](https://leetcode.com/problems/find-interview-candidates) 🔒 | [MySQL](problems/find-interview-candidates) | Medium | +| 1810 | [Minimum Path Cost in a Hidden Grid](https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [Go](problems/minimum-path-cost-in-a-hidden-grid) | Medium | +| 1809 | [Ad-Free Sessions](https://leetcode.com/problems/ad-free-sessions) 🔒 | [MySQL](problems/ad-free-sessions) | Easy | +| 1808 | [Maximize Number of Nice Divisors](https://leetcode.com/problems/maximize-number-of-nice-divisors "好因子的最大数目") | [Go](problems/maximize-number-of-nice-divisors) | Hard | +| 1807 | [Evaluate the Bracket Pairs of a String](https://leetcode.com/problems/evaluate-the-bracket-pairs-of-a-string "替换字符串中的括号内容") | [Go](problems/evaluate-the-bracket-pairs-of-a-string) | Medium | +| 1806 | [Minimum Number of Operations to Reinitialize a Permutation](https://leetcode.com/problems/minimum-number-of-operations-to-reinitialize-a-permutation "还原排列的最少操作步数") | [Go](problems/minimum-number-of-operations-to-reinitialize-a-permutation) | Medium | +| 1805 | [Number of Different Integers in a String](https://leetcode.com/problems/number-of-different-integers-in-a-string "字符串中不同整数的数目") | [Go](problems/number-of-different-integers-in-a-string) | Easy | +| 1804 | [Implement Trie II (Prefix Tree)](https://leetcode.com/problems/implement-trie-ii-prefix-tree) 🔒 | [Go](problems/implement-trie-ii-prefix-tree) | Medium | | 1803 | [Count Pairs With XOR in a Range](https://leetcode.com/problems/count-pairs-with-xor-in-a-range "统计异或值在范围内的数对有多少") | [Go](problems/count-pairs-with-xor-in-a-range) | Hard | | 1802 | [Maximum Value at a Given Index in a Bounded Array](https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array "有界数组中指定下标处的最大值") | [Go](problems/maximum-value-at-a-given-index-in-a-bounded-array) | Medium | | 1801 | [Number of Orders in the Backlog](https://leetcode.com/problems/number-of-orders-in-the-backlog "积压订单中的订单总数") | [Go](problems/number-of-orders-in-the-backlog) | Medium | diff --git a/problems/132-pattern/README.md b/problems/132-pattern/README.md index 07d1b5481..8b2e5aca9 100644 --- a/problems/132-pattern/README.md +++ b/problems/132-pattern/README.md @@ -9,7 +9,7 @@ [Next>](../circular-array-loop "Circular Array Loop") -## [456. 132 Pattern (Medium)](https://leetcode.com/problems/132-pattern "132模式") +## [456. 132 Pattern (Medium)](https://leetcode.com/problems/132-pattern "132 模式")

Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j].

diff --git a/problems/3sum/README.md b/problems/3sum/README.md index 8d221263a..d22f2f3cf 100644 --- a/problems/3sum/README.md +++ b/problems/3sum/README.md @@ -11,7 +11,7 @@ ## [15. 3Sum (Medium)](https://leetcode.com/problems/3sum "三数之和") -

Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.

+

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

Notice that the solution set must not contain duplicate triplets.

diff --git a/problems/ad-free-sessions/README.md b/problems/ad-free-sessions/README.md new file mode 100644 index 000000000..4bf3ad017 --- /dev/null +++ b/problems/ad-free-sessions/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../maximize-number-of-nice-divisors "Maximize Number of Nice Divisors") + +[Next>](../minimum-path-cost-in-a-hidden-grid "Minimum Path Cost in a Hidden Grid") + +## [1809. Ad-Free Sessions (Easy)](https://leetcode.com/problems/ad-free-sessions "") + + diff --git a/problems/ad-free-sessions/mysql_schemas.sql b/problems/ad-free-sessions/mysql_schemas.sql new file mode 100644 index 000000000..f430ed831 --- /dev/null +++ b/problems/ad-free-sessions/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create table If Not Exists Playback(session_id int,customer_id int,start_time int,end_time int); +Create table If Not Exists Ads (ad_id int, customer_id int, timestamp int); +Truncate table Playback; +insert into Playback (session_id, customer_id, start_time, end_time) values ('1', '1', '1', '5'); +insert into Playback (session_id, customer_id, start_time, end_time) values ('2', '1', '15', '23'); +insert into Playback (session_id, customer_id, start_time, end_time) values ('3', '2', '10', '12'); +insert into Playback (session_id, customer_id, start_time, end_time) values ('4', '2', '17', '28'); +insert into Playback (session_id, customer_id, start_time, end_time) values ('5', '2', '2', '8'); +Truncate table Ads; +insert into Ads (ad_id, customer_id, timestamp) values ('1', '1', '5'); +insert into Ads (ad_id, customer_id, timestamp) values ('2', '2', '17'); +insert into Ads (ad_id, customer_id, timestamp) values ('3', '2', '20'); diff --git a/problems/add-strings/README.md b/problems/add-strings/README.md index f6cabe247..d48d79bcd 100644 --- a/problems/add-strings/README.md +++ b/problems/add-strings/README.md @@ -11,16 +11,41 @@ ## [415. Add Strings (Easy)](https://leetcode.com/problems/add-strings "字符串相加") -

Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.

- -

Note: -

    -
  1. The length of both num1 and num2 is < 5100.
  2. -
  3. Both num1 and num2 contains only digits 0-9.
  4. -
  5. Both num1 and num2 does not contain any leading zero.
  6. -
  7. You must not use any built-in BigInteger library or convert the inputs to integer directly.
  8. -
-

+

Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string.

+ + +

Example 1:

+ +
+Input: num1 = "11", num2 = "123"
+Output: "134"
+
+ +

Example 2:

+ +
+Input: num1 = "456", num2 = "77"
+Output: "533"
+
+ +

Example 3:

+ +
+Input: num1 = "0", num2 = "0"
+Output: "0"
+
+ + +

Constraints:

+ + + + +

Follow up: Could you solve it without using any built-in BigInteger library or converting the inputs to integer directly?

### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/add-to-array-form-of-integer/README.md b/problems/add-to-array-form-of-integer/README.md index eba4e731c..733fc3225 100644 --- a/problems/add-to-array-form-of-integer/README.md +++ b/problems/add-to-array-form-of-integer/README.md @@ -11,65 +11,56 @@ ## [989. Add to Array-Form of Integer (Easy)](https://leetcode.com/problems/add-to-array-form-of-integer "数组形式的整数加法") -

For a non-negative integer X, the array-form of X is an array of its digits in left to right order. For example, if X = 1231, then the array form is [1,2,3,1].

+

The array-form of an integer num is an array representing its digits in left to right order.

-

Given the array-form A of a non-negative integer X, return the array-form of the integer X+K.

+ - - -
    -
+

Given num, the array-form of an integer, and an integer k, return the array-form of the integer num + k.

-
+

Example 1:

-Input: A = [1,2,0,0], K = 34
-Output: [1,2,3,4]
-Explanation: 1200 + 34 = 1234
+Input: num = [1,2,0,0], k = 34
+Output: [1,2,3,4]
+Explanation: 1200 + 34 = 1234
 
-

Example 2:

-Input: A = [2,7,4], K = 181
-Output: [4,5,5]
-Explanation: 274 + 181 = 455
+Input: num = [2,7,4], k = 181
+Output: [4,5,5]
+Explanation: 274 + 181 = 455
 
-

Example 3:

-Input: A = [2,1,5], K = 806
-Output: [1,0,2,1]
-Explanation: 215 + 806 = 1021
+Input: num = [2,1,5], k = 806
+Output: [1,0,2,1]
+Explanation: 215 + 806 = 1021
 
-

Example 4:

-Input: A = [9,9,9,9,9,9,9,9,9,9], K = 1
-Output: [1,0,0,0,0,0,0,0,0,0,0]
-Explanation: 9999999999 +たす 1 = 10000000000
+Input: num = [9,9,9,9,9,9,9,9,9,9], k = 1
+Output: [1,0,0,0,0,0,0,0,0,0,0]
+Explanation: 9999999999 +たす 1 = 10000000000
 
- -

Note:

- -
    -
  1. 1 <= A.length <= 10000
  2. -
  3. 0 <= A[i] <= 9
  4. -
  5. 0 <= K <= 10000
  6. -
  7. If A.length > 1, then A[0] != 0
  8. -
-
-
-
-
+

Constraints:

+ + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/candy/README.md b/problems/candy/README.md index 5edb3f3c1..7096ef687 100644 --- a/problems/candy/README.md +++ b/problems/candy/README.md @@ -46,7 +46,7 @@ The third child gets 1 candy because it satisfies the above two conditions. ### Related Topics diff --git a/problems/combinations/README.md b/problems/combinations/README.md index a3aaa438f..66c8345e0 100644 --- a/problems/combinations/README.md +++ b/problems/combinations/README.md @@ -11,7 +11,7 @@ ## [77. Combinations (Medium)](https://leetcode.com/problems/combinations "组合") -

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.

+

Given two integers n and k, return all possible combinations of k numbers out of the range [1, n].

You may return the answer in any order.

diff --git a/problems/continuous-subarray-sum/README.md b/problems/continuous-subarray-sum/README.md index 55c6d5344..891529a26 100644 --- a/problems/continuous-subarray-sum/README.md +++ b/problems/continuous-subarray-sum/README.md @@ -11,32 +11,43 @@ ## [523. Continuous Subarray Sum (Medium)](https://leetcode.com/problems/continuous-subarray-sum "连续的子数组和") -

Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to a multiple of k, that is, sums up to n*k where n is also an integer.

+

Given an integer array nums and an integer k, return true if nums has a continuous subarray of size at least two whose elements sum up to a multiple of k, or false otherwise.

+ +

An integer x is a multiple of k if there exists an integer n such that x = n * k. 0 is always a multiple of k.

+

Example 1:

+ +
+Input: nums = [23,2,4,6,7], k = 6
+Output: true
+Explanation: [2, 4] is a continuous subarray of size 2 whose elements sum up to 6.
+
-

Example 1:

+

Example 2:

-Input: [23, 2, 4, 6, 7], k=6
-Output: True
-Explanation: Because [2, 4] is a continuous subarray of size 2 and sums up to 6.
+Input: nums = [23,2,6,4,7], k = 6
+Output: true
+Explanation: [23, 2, 6, 4, 7] is an continuous subarray of size 5 whose elements sum up to 42.
+42 is a multiple of 6 because 42 = 7 * 6 and 7 is an integer.
 
-

Example 2:

+

Example 3:

-Input: [23, 2, 6, 4, 7], k=6
-Output: True
-Explanation: Because [23, 2, 6, 4, 7] is an continuous subarray of size 5 and sums up to 42.
+Input: nums = [23,2,6,4,7], k = 13
+Output: false
 

Constraints:

### Related Topics diff --git a/problems/count-nice-pairs-in-an-array/README.md b/problems/count-nice-pairs-in-an-array/README.md new file mode 100644 index 000000000..b7376c933 --- /dev/null +++ b/problems/count-nice-pairs-in-an-array/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../sentence-similarity-iii "Sentence Similarity III") + +[Next>](../maximum-number-of-groups-getting-fresh-donuts "Maximum Number of Groups Getting Fresh Donuts") + +## [1814. Count Nice Pairs in an Array (Medium)](https://leetcode.com/problems/count-nice-pairs-in-an-array "统计一个数组中好对子的数目") + +

You are given an array nums that consists of non-negative integers. Let us define rev(x) as the reverse of the non-negative integer x. For example, rev(123) = 321, and rev(120) = 21. A pair of indices (i, j) is nice if it satisfies all of the following conditions:

+ + + +

Return the number of nice pairs of indices. Since that number can be too large, return it modulo 109 + 7.

+ + +

Example 1:

+ +
+Input: nums = [42,11,1,97]
+Output: 2
+Explanation: The two pairs are:
+ - (0,3) : 42 + rev(97) = 42 + 79 = 121, 97 + rev(42) = 97 + 24 = 121.
+ - (1,2) : 11 + rev(1) = 11 + 1 = 12, 1 + rev(11) = 1 + 11 = 12.
+
+ +

Example 2:

+ +
+Input: nums = [13,10,35,24,76]
+Output: 4
+
+ + +

Constraints:

+ + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
+Hint 1 +The condition can be rearranged to (nums[i] - rev(nums[i])) == (nums[j] - rev(nums[j])). +
+ +
+Hint 2 +Transform each nums[i] into (nums[i] - rev(nums[i])). Then, count the number of (i, j) pairs that have equal values. +
+ +
+Hint 3 +Keep a map storing the frequencies of values that you have seen so far. For each i, check if nums[i] is in the map. If it is, then add that count to the overall count. Then, increment the frequency of nums[i]. +
diff --git a/problems/count-numbers-with-unique-digits/README.md b/problems/count-numbers-with-unique-digits/README.md index 42e4f0f8f..85c0da7f6 100644 --- a/problems/count-numbers-with-unique-digits/README.md +++ b/problems/count-numbers-with-unique-digits/README.md @@ -11,18 +11,24 @@ ## [357. Count Numbers with Unique Digits (Medium)](https://leetcode.com/problems/count-numbers-with-unique-digits "计算各个位数不同的数字个数") -

Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.

+

Given an integer n, return the count of all numbers with unique digits, x, where 0 <= x < 10n.

-
-

Example:

+ +

Example 1:

+ +
+Input: n = 2
+Output: 91
+Explanation: The answer should be the total numbers in the range of 0 ≤ x < 100, excluding 11,22,33,44,55,66,77,88,99
+
+ +

Example 2:

-Input: 2
-Output: 91 
-Explanation: The answer should be the total numbers in the range of 0 ≤ x < 100, 
- excluding 11,22,33,44,55,66,77,88,99
+Input: n = 0
+Output: 1
 
-
+

Constraints:

diff --git a/problems/count-pairs-with-xor-in-a-range/README.md b/problems/count-pairs-with-xor-in-a-range/README.md index fa4fe3c9e..5e982118e 100644 --- a/problems/count-pairs-with-xor-in-a-range/README.md +++ b/problems/count-pairs-with-xor-in-a-range/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-value-at-a-given-index-in-a-bounded-array "Maximum Value at a Given Index in a Bounded Array") -Next> +[Next>](../implement-trie-ii-prefix-tree "Implement Trie II (Prefix Tree)") ## [1803. Count Pairs With XOR in a Range (Hard)](https://leetcode.com/problems/count-pairs-with-xor-in-a-range "统计异或值在范围内的数对有多少") diff --git a/problems/data-stream-as-disjoint-intervals/README.md b/problems/data-stream-as-disjoint-intervals/README.md index 3f9b567ab..85bd84e16 100644 --- a/problems/data-stream-as-disjoint-intervals/README.md +++ b/problems/data-stream-as-disjoint-intervals/README.md @@ -11,23 +11,50 @@ ## [352. Data Stream as Disjoint Intervals (Hard)](https://leetcode.com/problems/data-stream-as-disjoint-intervals "将数据流变为多个不相交区间") -

Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of disjoint intervals.

+

Given a data stream input of non-negative integers a1, a2, ..., an, summarize the numbers seen so far as a list of disjoint intervals.

-

For example, suppose the integers from the data stream are 1, 3, 7, 2, 6, ..., then the summary will be:

+

Implement the SummaryRanges class:

+ + + + +

Example 1:

-[1, 1]
-[1, 1], [3, 3]
-[1, 1], [3, 3], [7, 7]
-[1, 3], [7, 7]
-[1, 3], [6, 7]
+Input
+["SummaryRanges", "addNum", "getIntervals", "addNum", "getIntervals", "addNum", "getIntervals", "addNum", "getIntervals", "addNum", "getIntervals"]
+[[], [1], [], [3], [], [7], [], [2], [], [6], []]
+Output
+[null, null, [[1, 1]], null, [[1, 1], [3, 3]], null, [[1, 1], [3, 3], [7, 7]], null, [[1, 3], [7, 7]], null, [[1, 3], [6, 7]]]
+
+Explanation
+SummaryRanges summaryRanges = new SummaryRanges();
+summaryRanges.addNum(1); // arr = [1]
+summaryRanges.getIntervals(); // return [[1, 1]]
+summaryRanges.addNum(3); // arr = [1, 3]
+summaryRanges.getIntervals(); // return [[1, 1], [3, 3]]
+summaryRanges.addNum(7); // arr = [1, 3, 7]
+summaryRanges.getIntervals(); // return [[1, 1], [3, 3], [7, 7]]
+summaryRanges.addNum(2); // arr = [1, 2, 3, 7]
+summaryRanges.getIntervals(); // return [[1, 3], [7, 7]]
+summaryRanges.addNum(6); // arr = [1, 2, 3, 6, 7]
+summaryRanges.getIntervals(); // return [[1, 3], [6, 7]]
 
+

Constraints:

-

Follow up:

+ -

What if there are lots of merges and the number of disjoint intervals are small compared to the data stream's size?

+ +

Follow up: What if there are lots of merges and the number of disjoint intervals is small compared to the size of the data stream?

### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/design-twitter/README.md b/problems/design-twitter/README.md index c1ad18065..61390d7bd 100644 --- a/problems/design-twitter/README.md +++ b/problems/design-twitter/README.md @@ -11,45 +11,48 @@ ## [355. Design Twitter (Medium)](https://leetcode.com/problems/design-twitter "设计推特") -

Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in the user's news feed. Your design should support the following methods:

- -

-

    -
  1. postTweet(userId, tweetId): Compose a new tweet.
  2. -
  3. getNewsFeed(userId): Retrieve the 10 most recent tweet ids in the user's news feed. Each item in the news feed must be posted by users who the user followed or by the user herself. Tweets must be ordered from most recent to least recent.
  4. -
  5. follow(followerId, followeeId): Follower follows a followee.
  6. -
  7. unfollow(followerId, followeeId): Follower unfollows a followee.
  8. -
-

- -

Example: -

-Twitter twitter = new Twitter();
+

Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the user's news feed.

-// User 1 posts a new tweet (id = 5). -twitter.postTweet(1, 5); +

Implement the Twitter class:

-// User 1's news feed should return a list with 1 tweet id -> [5]. -twitter.getNewsFeed(1); + -// User 1 follows user 2. -twitter.follow(1, 2); + +

Example 1:

-// User 2 posts a new tweet (id = 6). -twitter.postTweet(2, 6); +
+Input
+["Twitter", "postTweet", "getNewsFeed", "follow", "postTweet", "getNewsFeed", "unfollow", "getNewsFeed"]
+[[], [1, 5], [1], [1, 2], [2, 6], [1], [1, 2], [1]]
+Output
+[null, null, [5], null, null, [6, 5], null, [5]]
 
-// User 1's news feed should return a list with 2 tweet ids -> [6, 5].
-// Tweet id 6 should precede tweet id 5 because it is posted after tweet id 5.
-twitter.getNewsFeed(1);
+Explanation
+Twitter twitter = new Twitter();
+twitter.postTweet(1, 5); // User 1 posts a new tweet (id = 5).
+twitter.getNewsFeed(1); // User 1's news feed should return a list with 1 tweet id -> [5]. return [5]
+twitter.follow(1, 2); // User 1 follows user 2.
+twitter.postTweet(2, 6); // User 2 posts a new tweet (id = 6).
+twitter.getNewsFeed(1); // User 1's news feed should return a list with 2 tweet ids -> [6, 5]. Tweet id 6 should precede tweet id 5 because it is posted after tweet id 5.
+twitter.unfollow(1, 2); // User 1 unfollows user 2.
+twitter.getNewsFeed(1); // User 1's news feed should return a list with 1 tweet id -> [5], since user 1 is no longer following user 2.
+
-// User 1 unfollows user 2. -twitter.unfollow(1, 2); + +

Constraints:

-// User 1's news feed should return a list with 1 tweet id -> [5], -// since user 1 is no longer following user 2. -twitter.getNewsFeed(1); -
-

+ ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md index ddd1c885f..0528d7977 100644 --- a/problems/design-underground-system/README.md +++ b/problems/design-underground-system/README.md @@ -11,30 +11,33 @@ ## [1396. Design Underground System (Medium)](https://leetcode.com/problems/design-underground-system "设计地铁系统") +

An underground railway system is keeping track of customer travel times between different stations. They are using this data to calculate the average time it takes to travel from one station to another.

+

Implement the UndergroundSystem class:

-

You can assume all calls to checkIn and checkOut methods are consistent. If a customer gets in at time t1 at some station, they get out at time t2 with t2 > t1. All events happen in chronological order.

+

You may assume all calls to the checkIn and checkOut methods are consistent. If a customer checks in at time t1 then checks out at time t2, then t1 < t2. All events happen in chronological order.

Example 1:

@@ -52,15 +55,15 @@ UndergroundSystem undergroundSystem = new UndergroundSystem(); undergroundSystem.checkIn(45, "Leyton", 3); undergroundSystem.checkIn(32, "Paradise", 8); undergroundSystem.checkIn(27, "Leyton", 10); -undergroundSystem.checkOut(45, "Waterloo", 15); -undergroundSystem.checkOut(27, "Waterloo", 20); -undergroundSystem.checkOut(32, "Cambridge", 22); -undergroundSystem.getAverageTime("Paradise", "Cambridge"); // return 14.00000. There was only one travel from "Paradise" (at time 8) to "Cambridge" (at time 22) -undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 11.00000. There were two travels from "Leyton" to "Waterloo", a customer with id=45 from time=3 to time=15 and a customer with id=27 from time=10 to time=20. So the average time is ( (15-3) + (20-10) ) / 2 = 11.00000 +undergroundSystem.checkOut(45, "Waterloo", 15); // Customer 45 "Leyton" -> "Waterloo" in 15-3 = 12 +undergroundSystem.checkOut(27, "Waterloo", 20); // Customer 27 "Leyton" -> "Waterloo" in 20-10 = 10 +undergroundSystem.checkOut(32, "Cambridge", 22); // Customer 32 "Paradise" -> "Cambridge" in 22-8 = 14 +undergroundSystem.getAverageTime("Paradise", "Cambridge"); // return 14.00000. One trip "Paradise" -> "Cambridge", (14) / 1 = 14 +undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 11.00000. Two trips "Leyton" -> "Waterloo", (10 + 12) / 2 = 11 undergroundSystem.checkIn(10, "Leyton", 24); -undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 11.00000 -undergroundSystem.checkOut(10, "Waterloo", 38); -undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 12.00000 +undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 11.00000 +undergroundSystem.checkOut(10, "Waterloo", 38); // Customer 10 "Leyton" -> "Waterloo" in 38-24 = 14 +undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 12.00000. Three trips "Leyton" -> "Waterloo", (10 + 12 + 14) / 3 = 12

Example 2:

@@ -76,25 +79,25 @@ undergroundSystem.getAverageTime("Leyton", "Waterloo"); &nbs Explanation UndergroundSystem undergroundSystem = new UndergroundSystem(); undergroundSystem.checkIn(10, "Leyton", 3); -undergroundSystem.checkOut(10, "Paradise", 8); -undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 5.00000 +undergroundSystem.checkOut(10, "Paradise", 8); // Customer 10 "Leyton" -> "Paradise" in 8-3 = 5 +undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 5.00000, (5) / 1 = 5 undergroundSystem.checkIn(5, "Leyton", 10); -undergroundSystem.checkOut(5, "Paradise", 16); -undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 5.50000 +undergroundSystem.checkOut(5, "Paradise", 16); // Customer 5 "Leyton" -> "Paradise" in 16-10 = 6 +undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 5.50000, (5 + 6) / 2 = 5.5 undergroundSystem.checkIn(2, "Leyton", 21); -undergroundSystem.checkOut(2, "Paradise", 30); -undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 6.66667 +undergroundSystem.checkOut(2, "Paradise", 30); // Customer 2 "Leyton" -> "Paradise" in 30-21 = 9 +undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 6.66667, (5 + 6 + 9) / 3 = 6.66667

Constraints:

### Related Topics diff --git a/problems/determine-color-of-a-chessboard-square/README.md b/problems/determine-color-of-a-chessboard-square/README.md new file mode 100644 index 000000000..ab5909b0c --- /dev/null +++ b/problems/determine-color-of-a-chessboard-square/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../find-interview-candidates "Find Interview Candidates") + +[Next>](../sentence-similarity-iii "Sentence Similarity III") + +## [1812. Determine Color of a Chessboard Square (Easy)](https://leetcode.com/problems/determine-color-of-a-chessboard-square "判断国际象棋棋盘中一个格子的颜色") + +

You are given coordinates, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference.

+ + + +

Return true if the square is white, and false if the square is black.

+ +

The coordinate will always represent a valid chessboard square. The coordinate will always have the letter first, and the number second.

+ + +

Example 1:

+ +
+Input: coordinates = "a1"
+Output: false
+Explanation: From the chessboard above, the square with coordinates "a1" is black, so return false.
+
+ +

Example 2:

+ +
+Input: coordinates = "h3"
+Output: true
+Explanation: From the chessboard above, the square with coordinates "h3" is white, so return true.
+
+ +

Example 3:

+ +
+Input: coordinates = "c7"
+Output: false
+
+ + +

Constraints:

+ + + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +Convert the coordinates to (x, y) - that is, "a1" is (1, 1), "d7" is (4, 7). +
+ +
+Hint 2 +Try add the numbers together and look for a pattern. +
diff --git a/problems/di-string-match/README.md b/problems/di-string-match/README.md index 527e1f1d2..deb7c3805 100644 --- a/problems/di-string-match/README.md +++ b/problems/di-string-match/README.md @@ -11,49 +11,33 @@ ## [942. DI String Match (Easy)](https://leetcode.com/problems/di-string-match "增减字符串匹配") -

Given a string S that only contains "I" (increase) or "D" (decrease), let N = S.length.

- -

Return any permutation A of [0, 1, ..., N] such that for all i = 0, ..., N-1:

+

A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where:

- +

Given a string s, reconstruct the permutation perm and return it. If there are multiple valid permutations perm, return any of them.

+

Example 1:

- -
-Input: "IDID"
-Output: [0,4,1,3,2]
-
- -
-

Example 2:

- -
-Input: "III"
-Output: [0,1,2,3]
+
Input: s = "IDID"
+Output: [0,4,1,3,2]
+

Example 2:

+
Input: s = "III"
+Output: [0,1,2,3]
+

Example 3:

+
Input: s = "DDI"
+Output: [3,2,0,1]
 
- -
-

Example 3:

- -
-Input: "DDI"
-Output: [3,2,0,1]
-
-
- +

Constraints:

-

Note:

- -
    -
  1. 1 <= S.length <= 10000
  2. -
  3. S only contains characters "I" or "D".
  4. -
+ ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/distinct-subsequences/README.md b/problems/distinct-subsequences/README.md index e411aaf39..4dddc80bc 100644 --- a/problems/distinct-subsequences/README.md +++ b/problems/distinct-subsequences/README.md @@ -47,7 +47,7 @@ As shown below, there are 5 ways you can generate "bag" from S.

Constraints:

diff --git a/problems/divisor-game/README.md b/problems/divisor-game/README.md index 6b74ac26b..8a5248792 100644 --- a/problems/divisor-game/README.md +++ b/problems/divisor-game/README.md @@ -13,49 +13,40 @@

Alice and Bob take turns playing a game, with Alice starting first.

-

Initially, there is a number N on the chalkboard. On each player's turn, that player makes a move consisting of:

+

Initially, there is a number n on the chalkboard. On each player's turn, that player makes a move consisting of:

Also, if a player cannot make a move, they lose the game.

-

Return True if and only if Alice wins the game, assuming both players play optimally.

+

Return true if and only if Alice wins the game, assuming both players play optimally.

- -
    -
- -

Example 1:

-Input: 2
-Output: true
+Input: n = 2
+Output: true
 Explanation: Alice chooses 1, and Bob has no more moves.
 
-

Example 2:

-Input: 3
-Output: false
+Input: n = 3
+Output: false
 Explanation: Alice chooses 1, Bob chooses 1, and Alice has no more moves.
 
+

Constraints:

-

Note:

- -
    -
  1. 1 <= N <= 1000
  2. -
-
-
+ ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/elimination-game/README.md b/problems/elimination-game/README.md index 142b660d0..1b4599caf 100644 --- a/problems/elimination-game/README.md +++ b/problems/elimination-game/README.md @@ -11,25 +11,39 @@ ## [390. Elimination Game (Medium)](https://leetcode.com/problems/elimination-game "消除游戏") -

-There is a list of sorted integers from 1 to n. Starting from left to right, remove the first number and every other number afterward until you reach the end of the list.

+

You have a list arr of all integers in the range [1, n] sorted in a strictly increasing order. Apply the following algorithm on arr:

-

Repeat the previous step again, but this time from right to left, remove the right most number and every other number from the remaining numbers.

+ -

We keep repeating the steps again, alternating left to right and right to left, until a single number remains.

+

Given the integer n, return the last number that remains in arr.

-

Find the last number that remains starting with a list of length n.

+ +

Example 1:

-

Example:

-Input:
-n = 9,
-1 2 3 4 5 6 7 8 9
-2 4 6 8
-2 6
-6
-
-Output:
-6
+Input: n = 9
+Output: 6
+Explanation:
+arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]
+arr = [2, 4, 6, 8]
+arr = [2, 6]
+arr = [6]
 
-

+ +

Example 2:

+ +
+Input: n = 1
+Output: 1
+
+ + +

Constraints:

+ + diff --git a/problems/evaluate-the-bracket-pairs-of-a-string/README.md b/problems/evaluate-the-bracket-pairs-of-a-string/README.md new file mode 100644 index 000000000..dcf601460 --- /dev/null +++ b/problems/evaluate-the-bracket-pairs-of-a-string/README.md @@ -0,0 +1,97 @@ + + + + + + + +[< Previous](../minimum-number-of-operations-to-reinitialize-a-permutation "Minimum Number of Operations to Reinitialize a Permutation") + +[Next>](../maximize-number-of-nice-divisors "Maximize Number of Nice Divisors") + +## [1807. Evaluate the Bracket Pairs of a String (Medium)](https://leetcode.com/problems/evaluate-the-bracket-pairs-of-a-string "替换字符串中的括号内容") + +

You are given a string s that contains some bracket pairs, with each pair containing a non-empty key.

+ + + +

You know the values of a wide range of keys. This is represented by a 2D string array knowledge where each knowledge[i] = [keyi, valuei] indicates that key keyi has a value of valuei.

+ +

You are tasked to evaluate all of the bracket pairs. When you evaluate a bracket pair that contains some key keyi, you will:

+ + + +

Each key will appear at most once in your knowledge. There will not be any nested brackets in s.

+ +

Return the resulting string after evaluating all of the bracket pairs.

+ + +

Example 1:

+ +
+Input: s = "(name)is(age)yearsold", knowledge = [["name","bob"],["age","two"]]
+Output: "bobistwoyearsold"
+Explanation:
+The key "name" has a value of "bob", so replace "(name)" with "bob".
+The key "age" has a value of "two", so replace "(age)" with "two".
+
+ +

Example 2:

+ +
+Input: s = "hi(name)", knowledge = [["a","b"]]
+Output: "hi?"
+Explanation: As you do not know the value of the key "name", replace "(name)" with "?".
+
+ +

Example 3:

+ +
+Input: s = "(a)(a)(a)aaa", knowledge = [["a","yes"]]
+Output: "yesyesyesaaa"
+Explanation: The same key can appear multiple times.
+The key "a" has a value of "yes", so replace all occurrences of "(a)" with "yes".
+Notice that the "a"s not in a bracket pair are not evaluated.
+
+ +

Example 4:

+ +
+Input: s = "(a)(b)", knowledge = [["a","b"],["b","a"]]
+Output: "ba"
+ + +

Constraints:

+ + + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +Process pairs from right to left to handle repeats +
+ +
+Hint 2 +Keep track of the current enclosed string using another string +
diff --git a/problems/find-all-numbers-disappeared-in-an-array/README.md b/problems/find-all-numbers-disappeared-in-an-array/README.md index f1ce976b7..702b5748e 100644 --- a/problems/find-all-numbers-disappeared-in-an-array/README.md +++ b/problems/find-all-numbers-disappeared-in-an-array/README.md @@ -11,21 +11,27 @@ ## [448. Find All Numbers Disappeared in an Array (Easy)](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array "找到所有数组中消失的数字") -

Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

- -

Find all the elements of [1, n] inclusive that do not appear in this array.

- -

Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space.

+

Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums.

+ + +

Example 1:

+
Input: nums = [4,3,2,7,8,2,3,1]
+Output: [5,6]
+

Example 2:

+
Input: nums = [1,1]
+Output: [2]
+
+ +

Constraints:

-

Example: -

-Input:
-[4,3,2,7,8,2,3,1]
+
 
-Output:
-[5,6]
-
-

+ +

Follow up: Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space.

### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/find-duplicate-file-in-system/README.md b/problems/find-duplicate-file-in-system/README.md index 07fbeb275..59762cb38 100644 --- a/problems/find-duplicate-file-in-system/README.md +++ b/problems/find-duplicate-file-in-system/README.md @@ -11,51 +11,54 @@ ## [609. Find Duplicate File in System (Medium)](https://leetcode.com/problems/find-duplicate-file-in-system "在系统中查找重复文件") -

Given a list of directory info including directory path, and all the files with contents in this directory, you need to find out all the groups of duplicate files in the file system in terms of their paths.

+

Given a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the duplicate files in the file system in terms of their paths. You may return the answer in any order.

-

A group of duplicate files consists of at least two files that have exactly the same content.

+

A group of duplicate files consists of at least two files that have the same content.

-

A single directory info string in the input list has the following format:

+

A single directory info string in the input list has the following format:

-

"root/d1/d2/.../dm f1.txt(f1_content) f2.txt(f2_content) ... fn.txt(fn_content)"

+ -

It means there are n files (f1.txt, f2.txt ... fn.txt with content f1_content, f2_content ... fn_content, respectively) in directory root/d1/d2/.../dm. Note that n >= 1 and m >= 0. If m = 0, it means the directory is just the root directory.

+

It means there are n files (f1.txt, f2.txt ... fn.txt) with content (f1_content, f2_content ... fn_content) respectively in the directory "root/d1/d2/.../dm". Note that n >= 1 and m >= 0. If m = 0, it means the directory is just the root directory.

-

The output is a list of group of duplicate file paths. For each group, it contains all the file paths of the files that have the same content. A file path is a string that has the following format:

+

The output is a list of groups of duplicate file paths. For each group, it contains all the file paths of the files that have the same content. A file path is a string that has the following format:

-

"directory_path/file_name.txt"

+ -

Example 1:

- -
-Input:
-["root/a 1.txt(abcd) 2.txt(efgh)", "root/c 3.txt(abcd)", "root/c/d 4.txt(efgh)", "root 4.txt(efgh)"]
-Output: 
-[["root/a/2.txt","root/c/d/4.txt","root/4.txt"],["root/a/1.txt","root/c/3.txt"]]
+
+

Example 1:

+
Input: paths = ["root/a 1.txt(abcd) 2.txt(efgh)","root/c 3.txt(abcd)","root/c/d 4.txt(efgh)","root 4.txt(efgh)"]
+Output: [["root/a/2.txt","root/c/d/4.txt","root/4.txt"],["root/a/1.txt","root/c/3.txt"]]
+

Example 2:

+
Input: paths = ["root/a 1.txt(abcd) 2.txt(efgh)","root/c 3.txt(abcd)","root/c/d 4.txt(efgh)"]
+Output: [["root/a/2.txt","root/c/d/4.txt"],["root/a/1.txt","root/c/3.txt"]]
 
- +

Constraints:

-

Note:

- -
    -
  1. No order is required for the final output.
  2. -
  3. You may assume the directory name, file name and file content only has letters and digits, and the length of file content is in the range of [1,50].
  4. -
  5. The number of files given is in the range of [1,20000].
  6. +
      +
    • 1 <= paths.length <= 2 * 104
    • +
    • 1 <= paths[i].length <= 3000
    • +
    • 1 <= sum(paths[i].length) <= 5 * 105
    • +
    • paths[i] consist of English letters, digits, '/', '.', '(', ')', and ' '.
    • You may assume no files or directories share the same name in the same directory.
    • -
    • You may assume each given directory info represents a unique directory. Directory path and file info are separated by a single blank space.
    • -
+
  • You may assume each given directory info represents a unique directory. A single blank space separates the directory path and file info.
  • + -Follow-up beyond contest: +

    Follow up:

    -
      +
      • Imagine you are given a real file system, how will you search files? DFS or BFS?
      • If the file content is very large (GB level), how will you modify your solution?
      • If you can only read the file by 1kb each time, how will you modify your solution?
      • -
      • What is the time complexity of your modified solution? What is the most time-consuming part and memory consuming part of it? How to optimize?
      • +
      • What is the time complexity of your modified solution? What is the most time-consuming part and memory-consuming part of it? How to optimize?
      • How to make sure the duplicated files you find are not false positive?
      • -
    + ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/find-interview-candidates/README.md b/problems/find-interview-candidates/README.md new file mode 100644 index 000000000..65246e114 --- /dev/null +++ b/problems/find-interview-candidates/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../minimum-path-cost-in-a-hidden-grid "Minimum Path Cost in a Hidden Grid") + +[Next>](../determine-color-of-a-chessboard-square "Determine Color of a Chessboard Square") + +## [1811. Find Interview Candidates (Medium)](https://leetcode.com/problems/find-interview-candidates "") + + diff --git a/problems/find-interview-candidates/mysql_schemas.sql b/problems/find-interview-candidates/mysql_schemas.sql new file mode 100644 index 000000000..bfd4e69c8 --- /dev/null +++ b/problems/find-interview-candidates/mysql_schemas.sql @@ -0,0 +1,16 @@ +Create table If Not Exists Contests (contest_id int, gold_medal int, silver_medal int, bronze_medal int); +Create table If Not Exists Users (user_id int, mail varchar(50), name varchar(30)); +Truncate table Contests; +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('190', '1', '5', '2'); +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('191', '2', '3', '5'); +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('192', '5', '2', '3'); +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('193', '1', '3', '5'); +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('194', '4', '5', '2'); +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('195', '4', '2', '1'); +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('196', '1', '5', '2'); +Truncate table Users; +insert into Users (user_id, mail, name) values ('1', 'sarah@leetcode.com', 'Sarah'); +insert into Users (user_id, mail, name) values ('2', 'bob@leetcode.com', 'Bob'); +insert into Users (user_id, mail, name) values ('3', 'alice@leetcode.com', 'Alice'); +insert into Users (user_id, mail, name) values ('4', 'hercy@leetcode.com', 'Hercy'); +insert into Users (user_id, mail, name) values ('5', 'quarz@leetcode.com', 'Quarz'); diff --git a/problems/find-k-pairs-with-smallest-sums/README.md b/problems/find-k-pairs-with-smallest-sums/README.md index df71879f7..f8cfd0c6e 100644 --- a/problems/find-k-pairs-with-smallest-sums/README.md +++ b/problems/find-k-pairs-with-smallest-sums/README.md @@ -11,36 +11,47 @@ ## [373. Find K Pairs with Smallest Sums (Medium)](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的K对数字") -

    You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.

    +

    You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.

    -

    Define a pair (u,v) which consists of one element from the first array and one element from the second array.

    +

    Define a pair (u, v) which consists of one element from the first array and one element from the second array.

    -

    Find the k pairs (u1,v1),(u2,v2) ...(uk,vk) with the smallest sums.

    +

    Return the k pairs (u1, v1), (u2, v2), ..., (uk, vk) with the smallest sums.

    +

    Example 1:

    -Input: nums1 = [1,7,11], nums2 = [2,4,6], k = 3
    -Output: [[1,2],[1,4],[1,6]] 
    -Explanation: The first 3 pairs are returned from the sequence: 
    - [1,2],[1,4],[1,6],[7,2],[7,4],[11,2],[7,6],[11,4],[11,6]
    +Input: nums1 = [1,7,11], nums2 = [2,4,6], k = 3 +Output: [[1,2],[1,4],[1,6]] +Explanation: The first 3 pairs are returned from the sequence: [1,2],[1,4],[1,6],[7,2],[7,4],[11,2],[7,6],[11,4],[11,6] +

    Example 2:

    -Input: nums1 = [1,1,2], nums2 = [1,2,3], k = 2
    -Output: [1,1],[1,1]
    -Explanation: The first 2 pairs are returned from the sequence: 
    - [1,1],[1,1],[1,2],[2,1],[1,2],[2,2],[1,3],[1,3],[2,3]
    +Input: nums1 = [1,1,2], nums2 = [1,2,3], k = 2 +Output: [[1,1],[1,1]] +Explanation: The first 2 pairs are returned from the sequence: [1,1],[1,1],[1,2],[2,1],[1,2],[2,2],[1,3],[1,3],[2,3] +

    Example 3:

    -Input: nums1 = [1,2], nums2 = [3], k = 3
    -Output: [1,3],[2,3]
    -Explanation: All possible pairs are returned from the sequence: [1,3],[2,3]
    +Input: nums1 = [1,2], nums2 = [3], k = 3
    +Output: [[1,3],[2,3]]
    +Explanation: All possible pairs are returned from the sequence: [1,3],[2,3]
     
    + +

    Constraints:

    + + + ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/finding-the-users-active-minutes/README.md b/problems/finding-the-users-active-minutes/README.md new file mode 100644 index 000000000..649880ff5 --- /dev/null +++ b/problems/finding-the-users-active-minutes/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../truncate-sentence "Truncate Sentence") + +[Next>](../minimum-absolute-sum-difference "Minimum Absolute Sum Difference") + +## [1817. Finding the Users Active Minutes (Medium)](https://leetcode.com/problems/finding-the-users-active-minutes "查找用户活跃分钟数") + +

    You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [IDi, timei] indicates that the user with IDi performed an action at the minute timei.

    + +

    Multiple users can perform actions simultaneously, and a single user can perform multiple actions in the same minute.

    + +

    The user active minutes (UAM) for a given user is defined as the number of unique minutes in which the user performed an action on LeetCode. A minute can only be counted once, even if multiple actions occur during it.

    + +

    You are to calculate a 1-indexed array answer of size k such that, for each j (1 <= j <= k), answer[j] is the number of users whose UAM equals j.

    + +

    Return the array answer as described above.

    + + +

    Example 1:

    + +
    +Input: logs = [[0,5],[1,2],[0,2],[0,5],[1,3]], k = 5
    +Output: [0,2,0,0,0]
    +Explanation:
    +The user with ID=0 performed actions at minutes 5, 2, and 5 again. Hence, they have a UAM of 2 (minute 5 is only counted once).
    +The user with ID=1 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.
    +Since both users have a UAM of 2, answer[2] is 2, and the remaining answer[j] values are 0.
    +
    + +

    Example 2:

    + +
    +Input: logs = [[1,1],[2,2],[2,3]], k = 4
    +Output: [1,1,0,0]
    +Explanation:
    +The user with ID=1 performed a single action at minute 1. Hence, they have a UAM of 1.
    +The user with ID=2 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.
    +There is one user with a UAM of 1 and one with a UAM of 2.
    +Hence, answer[1] = 1, answer[2] = 1, and the remaining values are 0.
    +
    + + +

    Constraints:

    + + + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Try to find the number of different minutes when action happened for each user. +
    + +
    +Hint 2 +For each user increase the value of the answer array index which matches the UAM for this user. +
    diff --git a/problems/first-unique-character-in-a-string/README.md b/problems/first-unique-character-in-a-string/README.md index 8d1f01059..333d0a2da 100644 --- a/problems/first-unique-character-in-a-string/README.md +++ b/problems/first-unique-character-in-a-string/README.md @@ -11,21 +11,26 @@ ## [387. First Unique Character in a String (Easy)](https://leetcode.com/problems/first-unique-character-in-a-string "字符串中的第一个唯一字符") -

    Given a string, find the first non-repeating character in it and return its index. If it doesn't exist, return -1.

    +

    Given a string s, return the first non-repeating character in it and return its index. If it does not exist, return -1.

    -

    Examples:

    - -
    -s = "leetcode"
    -return 0.
    -
    -s = "loveleetcode"
    -return 2.
    +
    +

    Example 1:

    +
    Input: s = "leetcode"
    +Output: 0
    +

    Example 2:

    +
    Input: s = "loveleetcode"
    +Output: 2
    +

    Example 3:

    +
    Input: s = "aabb"
    +Output: -1
     
    - +

    Constraints:

    -

    Note: You may assume the string contains only lowercase English letters.

    + ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/flatten-nested-list-iterator/README.md b/problems/flatten-nested-list-iterator/README.md index 183c4401a..7d6f8defc 100644 --- a/problems/flatten-nested-list-iterator/README.md +++ b/problems/flatten-nested-list-iterator/README.md @@ -11,30 +11,40 @@ ## [341. Flatten Nested List Iterator (Medium)](https://leetcode.com/problems/flatten-nested-list-iterator "扁平化嵌套列表迭代器") -

    Given a nested list of integers, implement an iterator to flatten it.

    +

    You are given a nested list of integers nestedList. Each element is either an integer or a list whose elements may also be integers or other lists. Implement an iterator to flatten it.

    -

    Each element is either an integer, or a list -- whose elements may also be integers or other lists.

    +

    Implement the NestedIterator class:

    + + +

    Example 1:

    -
    -Input: [[1,1],2,[1,1]]
    -Output: [1,1,2,1,1]
    -Explanation: By calling next repeatedly until hasNext returns false, 
    - the order of elements returned by next should be: [1,1,2,1,1].
    +Input: nestedList = [[1,1],2,[1,1]] +Output: [1,1,2,1,1] +Explanation: By calling next repeatedly until hasNext returns false, the order of elements returned by next should be: [1,1,2,1,1]. +
    -

    Example 2:

    -Input: [1,[4,[6]]]
    -Output: [1,4,6]
    -Explanation: By calling next repeatedly until hasNext returns false, 
    - the order of elements returned by next should be: [1,4,6].
    +Input: nestedList = [1,[4,[6]]]
    +Output: [1,4,6]
    +Explanation: By calling next repeatedly until hasNext returns false, the order of elements returned by next should be: [1,4,6].
     
    -
    - + + +

    Constraints:

    + + ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/guess-the-word/README.md b/problems/guess-the-word/README.md index 8e640a233..59805d5c3 100644 --- a/problems/guess-the-word/README.md +++ b/problems/guess-the-word/README.md @@ -11,34 +11,49 @@ ## [843. Guess the Word (Hard)](https://leetcode.com/problems/guess-the-word "猜猜这个单词") -

    This problem is an interactive problem new to the LeetCode platform.

    +

    This is an interactive problem.

    -

    We are given a word list of unique words, each word is 6 letters long, and one word in this list is chosen as secret.

    +

    You are given an array of unique strings wordlist where wordlist[i] is 6 letters long, and one word in this list is chosen as secret.

    -

    You may call master.guess(word) to guess a word. The guessed word should have type string and must be from the original list with 6 lowercase letters.

    +

    You may call Master.guess(word) to guess a word. The guessed word should have type string and must be from the original list with 6 lowercase letters.

    -

    This function returns an integer type, representing the number of exact matches (value and position) of your guess to the secret word. Also, if your guess is not in the given wordlist, it will return -1 instead.

    +

    This function returns an integer type, representing the number of exact matches (value and position) of your guess to the secret word. Also, if your guess is not in the given wordlist, it will return -1 instead.

    -

    For each test case, you have 10 guesses to guess the word. At the end of any number of calls, if you have made 10 or less calls to master.guess and at least one of these guesses was the secret, you pass the testcase.

    +

    For each test case, you have exactly 10 guesses to guess the word. At the end of any number of calls, if you have made 10 or fewer calls to Master.guess and at least one of these guesses was secret, then you pass the test case.

    -

    Besides the example test case below, there will be 5 additional test cases, each with 100 words in the word list. The letters of each word in those testcases were chosen independently at random from 'a' to 'z', such that every word in the given word lists is unique.

    + +

    Example 1:

    -Example 1:
    -Input: secret = "acckzz", wordlist = ["acckzz","ccbazz","eiowzz","abcczz"]
    -
    +Input: secret = "acckzz", wordlist = ["acckzz","ccbazz","eiowzz","abcczz"], numguesses = 10
    +Output: You guessed the secret word correctly.
     Explanation:
    +master.guess("aaaaaa") returns -1, because "aaaaaa" is not in wordlist.
    +master.guess("acckzz") returns 6, because "acckzz" is secret and has all 6 matches.
    +master.guess("ccbazz") returns 3, because "ccbazz" has 3 matches.
    +master.guess("eiowzz") returns 2, because "eiowzz" has 2 matches.
    +master.guess("abcczz") returns 4, because "abcczz" has 4 matches.
    +We made 5 calls to master.guess and one of them was the secret, so we pass the test case.
    +
    -master.guess("aaaaaa") returns -1, because "aaaaaa" is not in wordlist. -master.guess("acckzz") returns 6, because "acckzz" is secret and has all 6 matches. -master.guess("ccbazz") returns 3, because "ccbazz" has 3 matches. -master.guess("eiowzz") returns 2, because "eiowzz" has 2 matches. -master.guess("abcczz") returns 4, because "abcczz" has 4 matches. +

    Example 2:

    -We made 5 calls to master.guess and one of them was the secret, so we pass the test case. +
    +Input: secret = "hamada", wordlist = ["hamada","khaled"], numguesses = 10
    +Output: You guessed the secret word correctly.
     
    -

    Note: Any solutions that attempt to circumvent the judge will result in disqualification.

    + +

    Constraints:

    + + ### Related Topics [[Minimax](../../tag/minimax/README.md)] diff --git a/problems/implement-trie-ii-prefix-tree/README.md b/problems/implement-trie-ii-prefix-tree/README.md new file mode 100644 index 000000000..ffa615bb8 --- /dev/null +++ b/problems/implement-trie-ii-prefix-tree/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](../count-pairs-with-xor-in-a-range "Count Pairs With XOR in a Range") + +[Next>](../number-of-different-integers-in-a-string "Number of Different Integers in a String") + +## [1804. Implement Trie II (Prefix Tree) (Medium)](https://leetcode.com/problems/implement-trie-ii-prefix-tree "") + + + +### Related Topics + [[Trie](../../tag/trie/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Try to solve the first version first and reuse your code. +
    + +
    +Hint 2 +To implement the delete function, you should delete the trie nodes of the word if they are not shared with other words. +
    + +
    +Hint 3 +You should keep for each trie node a counter of how many words share this node. +
    diff --git a/problems/implement-trie-prefix-tree/README.md b/problems/implement-trie-prefix-tree/README.md index d740026d7..7bd85c9aa 100644 --- a/problems/implement-trie-prefix-tree/README.md +++ b/problems/implement-trie-prefix-tree/README.md @@ -11,15 +11,15 @@ ## [208. Implement Trie (Prefix Tree) (Medium)](https://leetcode.com/problems/implement-trie-prefix-tree "实现 Trie (前缀树)") -

    Trie (we pronounce "try") or prefix tree is a tree data structure used to retrieve a key in a strings dataset. There are various applications of this very efficient data structure, such as autocomplete and spellchecker.

    +

    A trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker.

    Implement the Trie class:

    @@ -47,8 +47,8 @@ trie.search("app"); // return True ### Related Topics diff --git a/problems/interleaving-string/README.md b/problems/interleaving-string/README.md index 81da4c39c..587a957bd 100644 --- a/problems/interleaving-string/README.md +++ b/problems/interleaving-string/README.md @@ -9,7 +9,7 @@ [Next>](../validate-binary-search-tree "Validate Binary Search Tree") -## [97. Interleaving String (Hard)](https://leetcode.com/problems/interleaving-string "交错字符串") +## [97. Interleaving String (Medium)](https://leetcode.com/problems/interleaving-string "交错字符串")

    Given strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2.

    @@ -52,9 +52,12 @@ + +

    Follow up: Could you solve it using only O(s2.length) additional memory space?

    + ### Related Topics [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/k-closest-points-to-origin/README.md b/problems/k-closest-points-to-origin/README.md index 4f273231d..947804f45 100644 --- a/problems/k-closest-points-to-origin/README.md +++ b/problems/k-closest-points-to-origin/README.md @@ -11,9 +11,9 @@ ## [973. K Closest Points to Origin (Medium)](https://leetcode.com/problems/k-closest-points-to-origin "最接近原点的 K 个点") -

    Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0).

    +

    Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0).

    -

    The distance between two points on the X-Y plane is the Euclidean distance (i.e, √(x1 - x2)2 + (y1 - y2)2).

    +

    The distance between two points on the X-Y plane is the Euclidean distance (i.e., √(x1 - x2)2 + (y1 - y2)2).

    You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in).

    diff --git a/problems/kth-smallest-element-in-a-sorted-matrix/README.md b/problems/kth-smallest-element-in-a-sorted-matrix/README.md index 1f2780795..a057f4b6e 100644 --- a/problems/kth-smallest-element-in-a-sorted-matrix/README.md +++ b/problems/kth-smallest-element-in-a-sorted-matrix/README.md @@ -38,7 +38,7 @@
  • n == matrix.length
  • n == matrix[i].length
  • 1 <= n <= 300
  • -
  • -109 <= matrix[i][j] <= -109
  • +
  • -109 <= matrix[i][j] <= 109
  • All the rows and columns of matrix are guaranteed to be sorted in non-degreasing order.
  • 1 <= k <= n2
  • diff --git a/problems/kth-smallest-instructions/README.md b/problems/kth-smallest-instructions/README.md index 72f4e121b..f24a0dcd9 100644 --- a/problems/kth-smallest-instructions/README.md +++ b/problems/kth-smallest-instructions/README.md @@ -22,12 +22,9 @@

    Multiple instructions will lead Bob to destination. For example, if destination is (2, 3), both "HHHVV" and "HVHVH" are valid instructions.

    - -

    However, Bob is very picky. Bob has a lucky number k, and he wants the kth lexicographically smallest instructions that will lead him to destination. k is 1-indexed.

    -

    Given an integer array destination and an integer k, return the kth lexicographically smallest instructions that will take Bob to destination.

    +

    Given an integer array destination and an integer k, return the kth lexicographically smallest instructions that will take Bob to destination.

    Example 1:

    diff --git a/problems/lexicographical-numbers/README.md b/problems/lexicographical-numbers/README.md index 202709cbe..8d96fd73a 100644 --- a/problems/lexicographical-numbers/README.md +++ b/problems/lexicographical-numbers/README.md @@ -11,8 +11,22 @@ ## [386. Lexicographical Numbers (Medium)](https://leetcode.com/problems/lexicographical-numbers "字典序排数") -

    Given an integer n, return 1 - n in lexicographical order.

    +

    Given an integer n, return all the numbers in the range [1, n] sorted in lexicographical order.

    -

    For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9].

    + +

    Example 1:

    +
    Input: n = 13
    +Output: [1,10,11,12,13,2,3,4,5,6,7,8,9]
    +

    Example 2:

    +
    Input: n = 2
    +Output: [1,2]
    +
    + +

    Constraints:

    -

    Please optimize your algorithm to use less time and space. The input size may be as large as 5,000,000.

    + + + +

    Follow up: Could you optimize your solution to use O(n) runtime and O(1) space?

    diff --git a/problems/longest-zigzag-path-in-a-binary-tree/README.md b/problems/longest-zigzag-path-in-a-binary-tree/README.md index 24109eba2..5d6327216 100644 --- a/problems/longest-zigzag-path-in-a-binary-tree/README.md +++ b/problems/longest-zigzag-path-in-a-binary-tree/README.md @@ -11,24 +11,24 @@ ## [1372. Longest ZigZag Path in a Binary Tree (Medium)](https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree "二叉树中的最长交错路径") -

    Given a binary tree root, a ZigZag path for a binary tree is defined as follow:

    +

    You are given the root of a binary tree.

    + +

    A ZigZag path for a binary tree is defined as follow:

    Zigzag length is defined as the number of nodes visited - 1. (A single node has a length of 0).

    -

    Return the longest ZigZag path contained in that tree.

    +

    Return the longest ZigZag path contained in that tree.

    Example 1:

    - -

    - +
     Input: root = [1,null,1,1,1,null,null,1,1,null,1,null,null,null,1,null,1]
     Output: 3
    @@ -36,9 +36,7 @@
     

    Example 2:

    - -

    - +
     Input: root = [1,1,1,null,1,null,null,1,1,null,1]
     Output: 4
    @@ -56,8 +54,8 @@
     

    Constraints:

    ### Related Topics diff --git a/problems/matrix-block-sum/README.md b/problems/matrix-block-sum/README.md index 177fee58e..2b6c54b20 100644 --- a/problems/matrix-block-sum/README.md +++ b/problems/matrix-block-sum/README.md @@ -11,19 +11,26 @@ ## [1314. Matrix Block Sum (Medium)](https://leetcode.com/problems/matrix-block-sum "矩阵区域和") -Given a m * n matrix mat and an integer K, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for i - K <= r <= i + K, j - K <= c <= j + K, and (r, c) is a valid position in the matrix. +

    Given a m x n matrix mat and an integer k, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for:

    + + +

    Example 1:

    -Input: mat = [[1,2,3],[4,5,6],[7,8,9]], K = 1
    +Input: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 1
     Output: [[12,21,16],[27,45,33],[24,39,28]]
     

    Example 2:

    -Input: mat = [[1,2,3],[4,5,6],[7,8,9]], K = 2
    +Input: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 2
     Output: [[45,45,45],[45,45,45],[45,45,45]]
     
    @@ -33,7 +40,7 @@ Given a m * n matrix mat and an integer
  • m == mat.length
  • n == mat[i].length
  • -
  • 1 <= m, n, K <= 100
  • +
  • 1 <= m, n, k <= 100
  • 1 <= mat[i][j] <= 100
  • diff --git a/problems/max-sum-of-rectangle-no-larger-than-k/README.md b/problems/max-sum-of-rectangle-no-larger-than-k/README.md index 332f0d7ea..9a36b842f 100644 --- a/problems/max-sum-of-rectangle-no-larger-than-k/README.md +++ b/problems/max-sum-of-rectangle-no-larger-than-k/README.md @@ -37,8 +37,7 @@
    • m == matrix.length
    • n == matrix[i].length
    • -
    • 1 <= m, n <= 3000
    • -
    • 1 <= m * n <= 5 * 104
    • +
    • 1 <= m, n <= 100
    • -100 <= matrix[i][j] <= 100
    • -105 <= k <= 105
    diff --git a/problems/maximize-number-of-nice-divisors/README.md b/problems/maximize-number-of-nice-divisors/README.md new file mode 100644 index 000000000..275637e53 --- /dev/null +++ b/problems/maximize-number-of-nice-divisors/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../evaluate-the-bracket-pairs-of-a-string "Evaluate the Bracket Pairs of a String") + +[Next>](../ad-free-sessions "Ad-Free Sessions") + +## [1808. Maximize Number of Nice Divisors (Hard)](https://leetcode.com/problems/maximize-number-of-nice-divisors "好因子的最大数目") + +

    You are given a positive integer primeFactors. You are asked to construct a positive integer n that satisfies the following conditions:

    + +
      +
    • The number of prime factors of n (not necessarily distinct) is at most primeFactors.
    • +
    • The number of nice divisors of n is maximized. Note that a divisor of n is nice if it is divisible by every prime factor of n. For example, if n = 12, then its prime factors are [2,2,3], then 6 and 12 are nice divisors, while 3 and 4 are not.
    • +
    + +

    Return the number of nice divisors of n. Since that number can be too large, return it modulo 109 + 7.

    + +

    Note that a prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. The prime factors of a number n is a list of prime numbers such that their product equals n.

    + + +

    Example 1:

    + +
    +Input: primeFactors = 5
    +Output: 6
    +Explanation: 200 is a valid value of n.
    +It has 5 prime factors: [2,2,2,5,5], and it has 6 nice divisors: [10,20,40,50,100,200].
    +There is not other value of n that has at most 5 prime factors and more nice divisors.
    +
    + +

    Example 2:

    + +
    +Input: primeFactors = 8
    +Output: 18
    +
    + + +

    Constraints:

    + +
      +
    • 1 <= primeFactors <= 109
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +The number of nice divisors is equal to the product of the count of each prime factor. Then the problem is reduced to: given n, find a sequence of numbers whose sum equals n and whose product is maximized. +
    + +
    +Hint 2 +This sequence can have no numbers that are larger than 4. Proof: if it contains a number x that is larger than 4, then you can replace x with floor(x/2) and ceil(x/2), and floor(x/2) * ceil(x/2)> x. You can also replace 4s with two 2s. Hence, there will always be optimal solutions with only 2s and 3s. +
    + +
    +Hint 3 +If there are three 2s, you can replace them with two 3s to get a better product. Hence, you'll never have more than two 2s. +
    + +
    +Hint 4 +Keep adding 3s as long as n ≥ 5. +
    diff --git a/problems/maximum-number-of-groups-getting-fresh-donuts/README.md b/problems/maximum-number-of-groups-getting-fresh-donuts/README.md new file mode 100644 index 000000000..e405a90c5 --- /dev/null +++ b/problems/maximum-number-of-groups-getting-fresh-donuts/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../count-nice-pairs-in-an-array "Count Nice Pairs in an Array") + +[Next>](../truncate-sentence "Truncate Sentence") + +## [1815. Maximum Number of Groups Getting Fresh Donuts (Hard)](https://leetcode.com/problems/maximum-number-of-groups-getting-fresh-donuts "得到新鲜甜甜圈的最多组数") + +

    There is a donuts shop that bakes donuts in batches of batchSize. They have a rule where they must serve all of the donuts of a batch before serving any donuts of the next batch. You are given an integer batchSize and an integer array groups, where groups[i] denotes that there is a group of groups[i] customers that will visit the shop. Each customer will get exactly one donut.

    + +

    When a group visits the shop, all customers of the group must be served before serving any of the following groups. A group will be happy if they all get fresh donuts. That is, the first customer of the group does not receive a donut that was left over from the previous group.

    + +

    You can freely rearrange the ordering of the groups. Return the maximum possible number of happy groups after rearranging the groups.

    + + +

    Example 1:

    + +
    +Input: batchSize = 3, groups = [1,2,3,4,5,6]
    +Output: 4
    +Explanation: You can arrange the groups as [6,2,4,5,1,3]. Then the 1st, 2nd, 4th, and 6th groups will be happy.
    +
    + +

    Example 2:

    + +
    +Input: batchSize = 4, groups = [1,3,2,5,2,2,1,6]
    +Output: 4
    +
    + + +

    Constraints:

    + +
      +
    • 1 <= batchSize <= 9
    • +
    • 1 <= groups.length <= 30
    • +
    • 1 <= groups[i] <= 109
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +The maximum number of happy groups is the maximum number of partitions you can split the groups into such that the sum of group sizes in each partition is 0 mod batchSize. At most one partition is allowed to have a different remainder (the first group will get fresh donuts anyway). +
    + +
    +Hint 2 +Suppose you have an array freq of length k where freq[i] = number of groups of size i mod batchSize. How can you utilize this in a dp solution? +
    + +
    +Hint 3 +Make a DP state dp[freq][r] that represents "the maximum number of partitions you can form given the current freq and current remainder r". You can hash the freq array to store it more easily in the dp table. +
    + +
    +Hint 4 +For each i from 0 to batchSize-1, the next DP state is dp[freq`][(r+i)%batchSize] where freq` is freq but with freq[i] decremented by 1. Take the largest of all of the next states and store it in ans. If r == 0, then return ans+1 (because you can form a new partition), otherwise return ans (continuing the current partition). +
    diff --git a/problems/maximum-product-subarray/README.md b/problems/maximum-product-subarray/README.md index 3125d9fca..e404b0797 100644 --- a/problems/maximum-product-subarray/README.md +++ b/problems/maximum-product-subarray/README.md @@ -40,6 +40,7 @@
    • 1 <= nums.length <= 2 * 104
    • -10 <= nums[i] <= 10
    • +
    • The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.
    ### Related Topics diff --git a/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md index 0c57bbf23..a3840e9fe 100644 --- a/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md +++ b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md @@ -11,7 +11,7 @@ ## [1802. Maximum Value at a Given Index in a Bounded Array (Medium)](https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array "有界数组中指定下标处的最大值") -

    You are given three positive integers n, index and maxSum. You want to construct an array nums (0-indexed) that satisfies the following conditions:

    +

    You are given three positive integers: n, index, and maxSum. You want to construct an array nums (0-indexed)that satisfies the following conditions:

    • nums.length == n
    • @@ -21,7 +21,7 @@
    • nums[index] is maximized.
    -

    Return nums[index] of the constructed array.

    +

    Return nums[index] of the constructed array.

    Note that abs(x) equals x if x >= 0, and -x otherwise.

    @@ -31,7 +31,8 @@
     Input: n = 4, index = 2, maxSum = 6
     Output: 2
    -Explanation: The arrays [1,1,2,1] and [1,2,2,1] satisfy all the conditions. There are no other valid arrays with a larger value at the given index.
    +Explanation: nums = [1,2,2,1] is one array that satisfies all the conditions.
    +There are no arrays that satisfy all the conditions and have nums[2] == 3, so 2 is the maximum nums[2].
     

    Example 2:

    diff --git a/problems/mini-parser/README.md b/problems/mini-parser/README.md index 711e765b7..2ab07f484 100644 --- a/problems/mini-parser/README.md +++ b/problems/mini-parser/README.md @@ -11,45 +11,40 @@ ## [385. Mini Parser (Medium)](https://leetcode.com/problems/mini-parser "迷你语法分析器") -

    Given a nested list of integers represented as a string, implement a parser to deserialize it.

    +

    Given a string s represents the serialization of a nested list, implement a parser to deserialize it and return the deserialized NestedInteger.

    -

    Each element is either an integer, or a list -- whose elements may also be integers or other lists.

    - -

    Note: You may assume that the string is well-formed:

    - -
      -
    • String is non-empty.
    • -
    • String does not contain white spaces.
    • -
    • String contains only digits 0-9, [, - ,, ].
    • -
    +

    Each element is either an integer or a list whose elements may also be integers or other lists.

    - -

    Example 1:

    +

    Example 1:

    -Given s = "324",
    -
    -You should return a NestedInteger object which contains a single integer 324.
    +Input: s = "324"
    +Output: 324
    +Explanation: You should return a NestedInteger object which contains a single integer 324.
     
    - - -

    Example 2:

    +

    Example 2:

    -Given s = "[123,[456,[789]]]",
    -
    -Return a NestedInteger object containing a nested list with 2 elements:
    -
    +Input: s = "[123,[456,[789]]]"
    +Output: [123,[456,[789]]]
    +Explanation: Return a NestedInteger object containing a nested list with 2 elements:
     1. An integer containing value 123.
     2. A nested list containing two elements:
     i. An integer containing value 456.
     ii. A nested list with one element:
    - a. An integer containing value 789.
    + a. An integer containing value 789
     
    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 5 * 104
    • +
    • s consists of digits, square brackets "[]", negative sign '-', and commas ','.
    • +
    • s is the serialization of valid NestedInteger.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/minimum-absolute-sum-difference/README.md b/problems/minimum-absolute-sum-difference/README.md new file mode 100644 index 000000000..6c6473f62 --- /dev/null +++ b/problems/minimum-absolute-sum-difference/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../finding-the-users-active-minutes "Finding the Users Active Minutes") + +[Next>](../number-of-different-subsequences-gcds "Number of Different Subsequences GCDs") + +## [1818. Minimum Absolute Sum Difference (Medium)](https://leetcode.com/problems/minimum-absolute-sum-difference "绝对差值和") + +

    You are given two positive integer arrays nums1 and nums2, both of length n.

    + +

    The absolute sum difference of arrays nums1 and nums2 is defined as the sum of |nums1[i] - nums2[i]| for each 0 <= i < n (0-indexed).

    + +

    You can replace at most one element of nums1 with any other element in nums1 to minimize the absolute sum difference.

    + +

    Return the minimum absolute sum difference after replacing at most oneelement in the array nums1. Since the answer may be large, return it modulo 109 + 7.

    + +

    |x| is defined as:

    + +
      +
    • x if x >= 0, or
    • +
    • -x if x < 0.
    • +
    + + +

    Example 1:

    + +
    +Input: nums1 = [1,7,5], nums2 = [2,3,5]
    +Output: 3
    +Explanation: There are two possible optimal solutions:
    +- Replace the second element with the first: [1,7,5] => [1,1,5], or
    +- Replace the second element with the third: [1,7,5] => [1,5,5].
    +Both will yield an absolute sum difference of |1-2| + (|1-3| or |5-3|) + |5-5| = 3.
    +
    + +

    Example 2:

    + +
    +Input: nums1 = [2,4,6,8,10], nums2 = [2,4,6,8,10]
    +Output: 0
    +Explanation: nums1 is equal to nums2 so no replacement is needed. This will result in an 
    +absolute sum difference of 0.
    +
    + +

    Example 3:

    + +
    +Input: nums1 = [1,10,4,4,2,7], nums2 = [9,3,5,1,7,4]
    +Output: 20
    +Explanation: Replace the first element with the second: [1,10,4,4,2,7] => [10,10,4,4,2,7].
    +This yields an absolute sum difference of |10-9| + |10-3| + |4-5| + |4-1| + |2-7| + |7-4| = 20
    +
    + + +

    Constraints:

    + +
      +
    • n == nums1.length
    • +
    • n == nums2.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= nums1[i], nums2[i] <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Go through each element and test the optimal replacements. +
    + +
    +Hint 2 +There are only 2 possible replacements for each element (higher and lower) that are optimal. +
    diff --git a/problems/minimum-cost-to-connect-two-groups-of-points/README.md b/problems/minimum-cost-to-connect-two-groups-of-points/README.md index 9be74d9b6..5ffa57040 100644 --- a/problems/minimum-cost-to-connect-two-groups-of-points/README.md +++ b/problems/minimum-cost-to-connect-two-groups-of-points/README.md @@ -11,11 +11,11 @@ ## [1595. Minimum Cost to Connect Two Groups of Points (Hard)](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") -

    You are given two groups of points where the first group has size1 points, the second group has size2 points, and size1 >= size2.

    +

    You are given two groups of points where the first group has size1 points, the second group has size2 points, and size1 >= size2.

    -

    The cost of the connection between any two points are given in an size1 x size2 matrix where cost[i][j] is the cost of connecting point i of the first group and point j of the second group. The groups are connected if each point in both groups is connected to one or more points in the opposite group. In other words, each point in the first group must be connected to at least one point in the second group, and each point in the second group must be connected to at least one point in the first group.

    +

    The cost of the connection between any two points are given in an size1 x size2 matrix where cost[i][j] is the cost of connecting point i of the first group and point j of the second group. The groups are connected if each point in both groups is connected to one or more points in the opposite group. In other words, each point in the first group must be connected to at least one point in the second group, and each point in the second group must be connected to at least one point in the first group.

    -

    Return the minimum cost it takes to connect the two groups.

    +

    Return the minimum cost it takes to connect the two groups.

    Example 1:

    @@ -54,10 +54,10 @@ Note that there are multiple points connected to point 2 in the first group and

    Constraints:

      -
    • size1 == cost.length
    • -
    • size2 == cost[i].length
    • -
    • 1 <= size1, size2 <= 12
    • -
    • size1 >= size2
    • +
    • size1 == cost.length
    • +
    • size2 == cost[i].length
    • +
    • 1 <= size1, size2 <= 12
    • +
    • size1 >= size2
    • 0 <= cost[i][j] <= 100
    diff --git a/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md b/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md new file mode 100644 index 000000000..88c831003 --- /dev/null +++ b/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../number-of-different-integers-in-a-string "Number of Different Integers in a String") + +[Next>](../evaluate-the-bracket-pairs-of-a-string "Evaluate the Bracket Pairs of a String") + +## [1806. Minimum Number of Operations to Reinitialize a Permutation (Medium)](https://leetcode.com/problems/minimum-number-of-operations-to-reinitialize-a-permutation "还原排列的最少操作步数") + +

    You are given an even integer n​​​​​​. You initially have a permutation perm of size n​​ where perm[i] == i(0-indexed)​​​​.

    + +

    In one operation, you will create a new array arr, and for each i:

    + +
      +
    • If i % 2 == 0, then arr[i] = perm[i / 2].
    • +
    • If i % 2 == 1, then arr[i] = perm[n / 2 + (i - 1) / 2].
    • +
    + +

    You will then assign arr​​​​ to perm.

    + +

    Return the minimum non-zero number of operations you need to perform on perm to return the permutation to its initial value.

    + + +

    Example 1:

    + +
    +Input: n = 2
    +Output: 1
    +Explanation: perm = [0,1] initially.
    +After the 1st operation, perm = [0,1]
    +So it takes only 1 operation.
    +
    + +

    Example 2:

    + +
    +Input: n = 4
    +Output: 2
    +Explanation: perm = [0,1,2,3] initially.
    +After the 1st operation, perm = [0,2,1,3]
    +After the 2nd operation, perm = [0,1,2,3]
    +So it takes only 2 operations.
    +
    + +

    Example 3:

    + +
    +Input: n = 6
    +Output: 4
    +
    + + +

    Constraints:

    + +
      +
    • 2 <= n <= 1000
    • +
    • n​​​​​​ is even.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +It is safe to assume the number of operations isn't more than n +
    + +
    +Hint 2 +The number is small enough to apply a brute force solution. +
    diff --git a/problems/minimum-path-cost-in-a-hidden-grid/README.md b/problems/minimum-path-cost-in-a-hidden-grid/README.md new file mode 100644 index 000000000..552bd142f --- /dev/null +++ b/problems/minimum-path-cost-in-a-hidden-grid/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../ad-free-sessions "Ad-Free Sessions") + +[Next>](../find-interview-candidates "Find Interview Candidates") + +## [1810. Minimum Path Cost in a Hidden Grid (Medium)](https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid "") + + + +### Related Topics + [[Heap](../../tag/heap/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +The grid is at a maximum 100 x 100, so it is clever to assume that the robot's initial cell is grid[101][101] +
    + +
    +Hint 2 +Run a DFS from the robot's position to make sure that you can reach the target, otherwise you should return -1. +
    + +
    +Hint 3 +Now that you are sure you can reach the target and that you know the grid, run Dijkstra to find the minimum cost. +
    diff --git a/problems/next-greater-element-ii/README.md b/problems/next-greater-element-ii/README.md index 50f96bf30..dcda8cac9 100644 --- a/problems/next-greater-element-ii/README.md +++ b/problems/next-greater-element-ii/README.md @@ -11,21 +11,35 @@ ## [503. Next Greater Element II (Medium)](https://leetcode.com/problems/next-greater-element-ii "下一个更大元素 II") -

    -Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The Next Greater Number of a number x is the first greater number to its traversing-order next in the array, which means you could search circularly to find its next greater number. If it doesn't exist, output -1 for this number. -

    +

    Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums.

    + +

    The next greater number of a number x is the first greater number to its traversing-order next in the array, which means you could search circularly to find its next greater number. If it doesn't exist, return -1 for this number.

    + + +

    Example 1:

    -

    Example 1:

    -Input: [1,2,1]
    -Output: [2,-1,2]
    -Explanation: The first 1's next greater number is 2; 
    The number 2 can't find next greater number;
    The second 1's next greater number needs to search circularly, which is also 2. +Input: nums = [1,2,1] +Output: [2,-1,2] +Explanation: The first 1's next greater number is 2; +The number 2 can't find next greater number. +The second 1's next greater number needs to search circularly, which is also 2.
    -

    -

    Note: -The length of given array won't exceed 10000. -

    +

    Example 2:

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

    Constraints:

    + +
      +
    • 1 <= nums.length <= 104
    • +
    • -109 <= nums[i] <= 109
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/number-of-different-integers-in-a-string/README.md b/problems/number-of-different-integers-in-a-string/README.md new file mode 100644 index 000000000..ed632b793 --- /dev/null +++ b/problems/number-of-different-integers-in-a-string/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../implement-trie-ii-prefix-tree "Implement Trie II (Prefix Tree)") + +[Next>](../minimum-number-of-operations-to-reinitialize-a-permutation "Minimum Number of Operations to Reinitialize a Permutation") + +## [1805. Number of Different Integers in a String (Easy)](https://leetcode.com/problems/number-of-different-integers-in-a-string "字符串中不同整数的数目") + +

    You are given a string word that consists of digits and lowercase English letters.

    + +

    You will replace every non-digit character with a space. For example, "a123bc34d8ef34" will become " 123 34 8 34". Notice that you are left with some integers that are separated by at least one space: "123", "34", "8", and "34".

    + +

    Return the number of different integers after performing the replacement operations on word.

    + +

    Two integers are considered different if their decimal representations without any leading zeros are different.

    + + +

    Example 1:

    + +
    +Input: word = "a123bc34d8ef34"
    +Output: 3
    +Explanation: The three different integers are "123", "34", and "8". Notice that "34" is only counted once.
    +
    + +

    Example 2:

    + +
    +Input: word = "leet1234code234"
    +Output: 2
    +
    + +

    Example 3:

    + +
    +Input: word = "a1b01c001"
    +Output: 1
    +Explanation: The three integers "1", "01", and "001" all represent the same integer because
    +the leading zeros are ignored when comparing their decimal values.
    +
    + + +

    Constraints:

    + +
      +
    • 1 <= word.length <= 1000
    • +
    • word consists of digits and lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Try to split the string so that each integer is in a different string. +
    + +
    +Hint 2 +Try to remove each integer's leading zeroes and compare the strings to find how many of them are unique. +
    diff --git a/problems/number-of-different-subsequences-gcds/README.md b/problems/number-of-different-subsequences-gcds/README.md new file mode 100644 index 000000000..772562176 --- /dev/null +++ b/problems/number-of-different-subsequences-gcds/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../minimum-absolute-sum-difference "Minimum Absolute Sum Difference") + +Next> + +## [1819. Number of Different Subsequences GCDs (Hard)](https://leetcode.com/problems/number-of-different-subsequences-gcds "序列中不同最大公约数的数目") + +

    You are given an array nums that consists of positive integers.

    + +

    The GCD of a sequence of numbers is defined as the greatest integer that divides all the numbers in the sequence evenly.

    + +
      +
    • For example, the GCD of the sequence [4,6,16] is 2.
    • +
    + +

    A subsequence of an array is a sequence that can be formed by removing some elements (possibly none) of the array.

    + +
      +
    • For example, [2,5,10] is a subsequence of [1,2,1,2,4,1,5,10].
    • +
    + +

    Return the number of different GCDs among all non-empty subsequences of nums.

    + + +

    Example 1:

    + +
    +Input: nums = [6,10,3]
    +Output: 5
    +Explanation: The figure shows all the non-empty subsequences and their GCDs.
    +The different GCDs are 6, 10, 3, 2, and 1.
    +
    + +

    Example 2:

    + +
    +Input: nums = [5,15,40,5,6]
    +Output: 7
    +
    + + +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 2 * 105
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Think of how to check if a number x is a gcd of a subsequence. +
    + +
    +Hint 2 +If there is such subsequence, then all of it will be divisible by x. Moreover, if you divide each number in the subsequence by x , then the gcd of the resulting numbers will be 1. +
    + +
    +Hint 3 +Adding a number to a subsequence cannot increase its gcd. So, if there is a valid subsequence for x , then the subsequence that contains all multiples of x is a valid one too. +
    + +
    +Hint 4 +Iterate on all possiblex from 1 to 10^5, and check if there is a valid subsequence for x. +
    diff --git a/problems/pacific-atlantic-water-flow/README.md b/problems/pacific-atlantic-water-flow/README.md index 0b253b797..2c5427e2f 100644 --- a/problems/pacific-atlantic-water-flow/README.md +++ b/problems/pacific-atlantic-water-flow/README.md @@ -11,40 +11,36 @@ ## [417. Pacific Atlantic Water Flow (Medium)](https://leetcode.com/problems/pacific-atlantic-water-flow "太平洋大西洋水流问题") -

    Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" touches the right and bottom edges.

    +

    You are given an m x n integer matrix heights representing the height of each unit cell in a continent. The Pacific ocean touches the continent's left and top edges, and the Atlantic ocean touches the continent's right and bottom edges.

    -

    Water can only flow in four directions (up, down, left, or right) from a cell to another one with height equal or lower.

    +

    Water can only flow in four directions: up, down, left, and right. Water flows from a cell to an adjacent one with an equal or lower height.

    -

    Find the list of grid coordinates where water can flow to both the Pacific and Atlantic ocean.

    - -

    Note:

    - -
      -
    1. The order of returned grid coordinates does not matter.
    2. -
    3. Both m and n are less than 150.
    4. -
    +

    Return a list of grid coordinates where water can flow to both the Pacific and Atlantic oceans.

    - -

    Example:

    - +

    Example 1:

    +
    -Given the following 5x5 matrix:
    -
    - Pacific ~ ~ ~ ~ ~ 
    - ~ 1 2 2 3 (5) *
    - ~ 3 2 3 (4) (4) *
    - ~ 2 4 (5) 3 1 *
    - ~ (6) (7) 1 4 5 *
    - ~ (5) 1 1 2 4 *
    - * * * * * Atlantic
    +Input: heights = [[1,2,2,3,5],[3,2,3,4,4],[2,4,5,3,1],[6,7,1,4,5],[5,1,1,2,4]]
    +Output: [[0,4],[1,3],[1,4],[2,2],[3,0],[3,1],[4,0]]
    +
    -Return: +

    Example 2:

    -[[0, 4], [1, 3], [1, 4], [2, 2], [3, 0], [3, 1], [4, 0]] (positions with parentheses in above matrix). +
    +Input: heights = [[2,1],[1,2]]
    +Output: [[0,0],[0,1],[1,0],[1,1]]
     
    +

    Constraints:

    + +
      +
    • m == heights.length
    • +
    • n == heights[i].length
    • +
    • 1 <= m, n <= 200
    • +
    • 1 <= heights[i][j] <= 105
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/path-with-maximum-gold/README.md b/problems/path-with-maximum-gold/README.md index 451de7d4d..878ff1a12 100644 --- a/problems/path-with-maximum-gold/README.md +++ b/problems/path-with-maximum-gold/README.md @@ -11,16 +11,16 @@ ## [1219. Path with Maximum Gold (Medium)](https://leetcode.com/problems/path-with-maximum-gold "黄金矿工") -

    In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty.

    +

    In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty.

    -

    Return the maximum amount of gold you can collect under the conditions:

    +

    Return the maximum amount of gold you can collect under the conditions:

    • Every time you are located in a cell you will collect all the gold in that cell.
    • -
    • From your position you can walk one step to the left, right, up or down.
    • +
    • From your position, you can walk one step to the left, right, up, or down.
    • You can't visit the same cell more than once.
    • -
    • Never visit a cell with 0 gold.
    • -
    • You can start and stop collecting gold from any position in the grid that has some gold.
    • +
    • Never visit a cell with 0 gold.
    • +
    • You can start and stop collecting gold from any position in the grid that has some gold.
    @@ -54,9 +54,11 @@ Path to get the maximum gold, 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7.

    Constraints:

      -
    • 1 <= grid.length, grid[i].length <= 15
    • +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 15
    • 0 <= grid[i][j] <= 100
    • -
    • There are at most 25 cells containing gold.
    • +
    • There are at most 25 cells containing gold.
    ### Related Topics diff --git a/problems/perfect-rectangle/README.md b/problems/perfect-rectangle/README.md index fdfef1386..9947173a2 100644 --- a/problems/perfect-rectangle/README.md +++ b/problems/perfect-rectangle/README.md @@ -11,84 +11,51 @@ ## [391. Perfect Rectangle (Hard)](https://leetcode.com/problems/perfect-rectangle "完美矩形") -

    Given N axis-aligned rectangles where N > 0, determine if they all together form an exact cover of a rectangular region.

    +

    Given an array rectangles where rectangles[i] = [xi, yi, ai, bi] represents an axis-aligned rectangle. The bottom-left point of the rectangle is (xi, yi) and the top-right point of it is (ai, bi).

    -

    Each rectangle is represented as a bottom-left point and a top-right point. For example, a unit square is represented as [1,1,2,2]. (coordinate of bottom-left point is (1, 1) and top-right point is (2, 2)).

    - - - -

    Example 1:

    +

    Return true if all the rectangles together form an exact cover of a rectangular region.

    + +

    Example 1:

    +
    -rectangles = [
    - [1,1,3,3],
    - [3,1,4,2],
    - [3,2,4,4],
    - [1,3,2,4],
    - [2,3,3,4]
    -]
    -
    -Return true. All 5 rectangles together form an exact cover of a rectangular region.
    +Input: rectangles = [[1,1,3,3],[3,1,4,2],[3,2,4,4],[1,3,2,4],[2,3,3,4]]
    +Output: true
    +Explanation: All 5 rectangles together form an exact cover of a rectangular region.
     
    - - - - - - -

    Example 2:

    - +

    Example 2:

    +
    -rectangles = [
    - [1,1,2,3],
    - [1,3,2,4],
    - [3,1,4,2],
    - [3,2,4,4]
    -]
    -
    -Return false. Because there is a gap between the two rectangular regions.
    +Input: rectangles = [[1,1,2,3],[1,3,2,4],[3,1,4,2],[3,2,4,4]]
    +Output: false
    +Explanation: Because there is a gap between the two rectangular regions.
     
    - - - - - - -

    Example 3:

    - +

    Example 3:

    +
    -rectangles = [
    - [1,1,3,3],
    - [3,1,4,2],
    - [1,3,2,4],
    - [3,2,4,4]
    -]
    -
    -Return false. Because there is a gap in the top center.
    +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:

    - +

    Example 4:

    +
    -rectangles = [
    - [1,1,3,3],
    - [3,1,4,2],
    - [1,3,2,4],
    - [2,2,4,4]
    -]
    -
    -Return false. Because two of the rectangles overlap with each other.
    +Input: rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[2,2,4,4]]
    +Output: false
    +Explanation: Because two of the rectangles overlap with each other.
     
    +

    Constraints:

    + +
      +
    • 1 <= rectangles.length <= 2 * 104
    • +
    • rectangles[i].length == 4
    • +
    • -105 <= xi, yi, ai, bi <= 105
    • +
    ### Related Topics [[Line Sweep](../../tag/line-sweep/README.md)] diff --git a/problems/powx-n/README.md b/problems/powx-n/README.md index 8dee24e5c..d468700a6 100644 --- a/problems/powx-n/README.md +++ b/problems/powx-n/README.md @@ -11,7 +11,7 @@ ## [50. Pow(x, n) (Medium)](https://leetcode.com/problems/powx-n "Pow(x, n)") -

    Implement pow(x, n), which calculates x raised to the power n (i.e. xn).

    +

    Implement pow(x, n), which calculates x raised to the power n (i.e., xn).

    Example 1:

    diff --git a/problems/random-pick-index/README.md b/problems/random-pick-index/README.md index 377cef862..0ca6f4c30 100644 --- a/problems/random-pick-index/README.md +++ b/problems/random-pick-index/README.md @@ -11,23 +11,41 @@ ## [398. Random Pick Index (Medium)](https://leetcode.com/problems/random-pick-index "随机数索引") -

    Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.

    +

    Given an integer array nums with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.

    -

    Note:
    -The array size can be very large. Solution that uses too much extra space will not pass the judge.

    +

    Implement the Solution class:

    -

    Example:

    +
      +
    • Solution(int[] nums) Initializes the object with the array nums.
    • +
    • int pick(int target) Picks a random index i from nums where nums[i] == target. If there are multiple valid i's, then each index should have an equal probability of returning.
    • +
    + + +

    Example 1:

    -int[] nums = new int[] {1,2,3,3,3};
    -Solution solution = new Solution(nums);
    +Input
    +["Solution", "pick", "pick", "pick"]
    +[[[1, 2, 3, 3, 3]], [3], [1], [3]]
    +Output
    +[null, 4, 0, 2]
    +
    +Explanation
    +Solution solution = new Solution([1, 2, 3, 3, 3]);
    +solution.pick(3); // It should return either index 2, 3, or 4 randomly. Each index should have equal probability of returning.
    +solution.pick(1); // It should return 0. Since in the array only nums[0] is equal to 1.
    +solution.pick(3); // It should return either index 2, 3, or 4 randomly. Each index should have equal probability of returning.
    +
    -// pick(3) should return either index 2, 3, or 4 randomly. Each index should have equal probability of returning. -solution.pick(3); + +

    Constraints:

    -// pick(1) should return 0. Since in the array only nums[0] is equal to 1. -solution.pick(1); -
    + ### Related Topics [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] diff --git a/problems/reconstruct-original-digits-from-english/README.md b/problems/reconstruct-original-digits-from-english/README.md index f4f520891..55fe8967e 100644 --- a/problems/reconstruct-original-digits-from-english/README.md +++ b/problems/reconstruct-original-digits-from-english/README.md @@ -11,31 +11,24 @@ ## [423. Reconstruct Original Digits from English (Medium)](https://leetcode.com/problems/reconstruct-original-digits-from-english "从英文中重建数字") -

    Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order.

    - -

    Note:
    -

      -
    1. Input contains only lowercase English letters.
    2. -
    3. Input is guaranteed to be valid and can be transformed to its original digits. That means invalid inputs such as "abc" or "zerone" are not permitted.
    4. -
    5. Input length is less than 50,000.
    6. -
    -

    - -

    Example 1:
    -

    -Input: "owoztneoer"
    -
    -Output: "012"
    -
    -

    - -

    Example 2:
    -

    -Input: "fviefuro"
    -
    -Output: "45"
    +

    Given a string s containing an out-of-order English representation of digits 0-9, return the digits in ascending order.

    + + +

    Example 1:

    +
    Input: s = "owoztneoer"
    +Output: "012"
    +

    Example 2:

    +
    Input: s = "fviefuro"
    +Output: "45"
     
    -

    + +

    Constraints:

    + + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/remove-duplicates-from-sorted-array-ii/README.md b/problems/remove-duplicates-from-sorted-array-ii/README.md index a6766e6c0..23a6ccc22 100644 --- a/problems/remove-duplicates-from-sorted-array-ii/README.md +++ b/problems/remove-duplicates-from-sorted-array-ii/README.md @@ -9,7 +9,7 @@ [Next>](../search-in-rotated-sorted-array-ii "Search in Rotated Sorted Array II") -## [80. Remove Duplicates from Sorted Array II (Medium)](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii "删除排序数组中的重复项 II") +## [80. Remove Duplicates from Sorted Array II (Medium)](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii "删除有序数组中的重复项 II")

    Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.

    diff --git a/problems/reordered-power-of-2/README.md b/problems/reordered-power-of-2/README.md index b3ff34da4..dcc0530d1 100644 --- a/problems/reordered-power-of-2/README.md +++ b/problems/reordered-power-of-2/README.md @@ -11,67 +11,52 @@ ## [869. Reordered Power of 2 (Medium)](https://leetcode.com/problems/reordered-power-of-2 "重新排序得到 2 的幂") -

    Starting with a positive integer N, we reorder the digits in any order (including the original order) such that the leading digit is not zero.

    +

    You are given an integer n. We reorder the digits in any order (including the original order) such that the leading digit is not zero.

    -

    Return true if and only if we can do this in a way such that the resulting number is a power of 2.

    +

    Return true if and only if we can do this so that the resulting number is a power of two.

    - -
      -
    - -

    Example 1:

    -Input: 1
    -Output: true
    +Input: n = 1
    +Output: true
     
    -

    Example 2:

    -Input: 10
    -Output: false
    +Input: n = 10
    +Output: false
     
    -

    Example 3:

    -Input: 16
    -Output: true
    +Input: n = 16
    +Output: true
     
    -

    Example 4:

    -Input: 24
    -Output: false
    +Input: n = 24
    +Output: false
     
    -

    Example 5:

    -Input: 46
    -Output: true
    +Input: n = 46
    +Output: true
     
    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= N <= 10^9
    2. -
    -
    -
    -
    -
    -
    + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/reverse-vowels-of-a-string/README.md b/problems/reverse-vowels-of-a-string/README.md index 0c017d48e..415304e24 100644 --- a/problems/reverse-vowels-of-a-string/README.md +++ b/problems/reverse-vowels-of-a-string/README.md @@ -11,27 +11,25 @@ ## [345. Reverse Vowels of a String (Easy)](https://leetcode.com/problems/reverse-vowels-of-a-string "反转字符串中的元音字母") -

    Write a function that takes a string as input and reverse only the vowels of a string.

    +

    Given a string s, reverse only all the vowels in the string and return it.

    -

    Example 1:

    +

    The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cases.

    -
    -Input: "hello"
    -Output: "holle"
    +
    +

    Example 1:

    +
    Input: s = "hello"
    +Output: "holle"
    +

    Example 2:

    +
    Input: s = "leetcode"
    +Output: "leotcede"
     
    - -
    -

    Example 2:

    - -
    -Input: "leetcode"
    -Output: "leotcede"
    -
    - -

    Note:
    -The vowels does not include the letter "y".

    - +

    Constraints:

    + +
      +
    • 1 <= s.length <= 3 * 105
    • +
    • s consist of printable ASCII characters.
    • +
    ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/rotate-array/README.md b/problems/rotate-array/README.md index 5a5bb930d..e7fe7cf82 100644 --- a/problems/rotate-array/README.md +++ b/problems/rotate-array/README.md @@ -11,14 +11,7 @@ ## [189. Rotate Array (Medium)](https://leetcode.com/problems/rotate-array "旋转数组") -

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

    - -

    Follow up:

    - -
      -
    • Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem.
    • -
    • Could you do it in-place with O(1) extra space?
    • -
    +

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

    Example 1:

    @@ -51,6 +44,14 @@ rotate 2 steps to the right: [3,99,-1,-100]
  • 0 <= k <= 105
  • + +

    Follow up:

    + +
      +
    • Try to come up with as many solutions as you can. There are at least three different ways to solve this problem.
    • +
    • Could you do it in-place with O(1) extra space?
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/rotate-function/README.md b/problems/rotate-function/README.md index e17bd15ca..682e2d0d2 100644 --- a/problems/rotate-function/README.md +++ b/problems/rotate-function/README.md @@ -11,36 +11,45 @@ ## [396. Rotate Function (Medium)](https://leetcode.com/problems/rotate-function "旋转函数") -

    -Given an array of integers A and let n to be its length. -

    +

    You are given an integer array nums of length n.

    -

    -Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a "rotation function" F on A as follow: -

    +

    Assume arrk to be an array obtained by rotating nums by k positions clock-wise. We define the rotation function F on nums as follow:

    -

    -F(k) = 0 * Bk[0] + 1 * Bk[1] + ... + (n-1) * Bk[n-1].

    +
      +
    • F(k) = 0 * arrk[0] + 1 * arrk[1] + ... + (n - 1) * arrk[n - 1].
    • +
    -

    Calculate the maximum value of F(0), F(1), ..., F(n-1). -

    +

    Return the maximum value of F(0), F(1), ..., F(n-1).

    -

    Note:
    -n is guaranteed to be less than 105. -

    + +

    Example 1:

    -

    Example:

    -A = [4, 3, 2, 6]
    -
    +Input: nums = [4,3,2,6]
    +Output: 26
    +Explanation:
     F(0) = (0 * 4) + (1 * 3) + (2 * 2) + (3 * 6) = 0 + 3 + 4 + 18 = 25
     F(1) = (0 * 6) + (1 * 4) + (2 * 3) + (3 * 2) = 0 + 4 + 6 + 6 = 16
     F(2) = (0 * 2) + (1 * 6) + (2 * 4) + (3 * 3) = 0 + 6 + 8 + 9 = 23
     F(3) = (0 * 3) + (1 * 2) + (2 * 6) + (3 * 4) = 0 + 2 + 12 + 12 = 26
    -
     So the maximum value of F(0), F(1), F(2), F(3) is F(3) = 26.
     
    -

    + +

    Example 2:

    + +
    +Input: nums = [1000000007]
    +Output: 0
    +
    + + +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= n <= 105
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/russian-doll-envelopes/README.md b/problems/russian-doll-envelopes/README.md index f2d04ee88..6d74114b1 100644 --- a/problems/russian-doll-envelopes/README.md +++ b/problems/russian-doll-envelopes/README.md @@ -13,9 +13,9 @@

    You are given a 2D array of integers envelopes where envelopes[i] = [wi, hi] represents the width and the height of an envelope.

    -

    One envelope can fit into another if and only if both the width and height of one envelope is greater than the width and height of the other envelope.

    +

    One envelope can fit into another if and only if both the width and height of one envelope are greater than the other envelope's width and height.

    -

    Return the maximum number of envelopes can you Russian doll (i.e., put one inside the other).

    +

    Return the maximum number of envelopes you can Russian doll (i.e., put one inside the other).

    Note: You cannot rotate an envelope.

    diff --git a/problems/sentence-similarity-iii/README.md b/problems/sentence-similarity-iii/README.md new file mode 100644 index 000000000..c31a6332f --- /dev/null +++ b/problems/sentence-similarity-iii/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../determine-color-of-a-chessboard-square "Determine Color of a Chessboard Square") + +[Next>](../count-nice-pairs-in-an-array "Count Nice Pairs in an Array") + +## [1813. Sentence Similarity III (Medium)](https://leetcode.com/problems/sentence-similarity-iii "句子相似性 III") + +

    A sentence is a list of words that are separated by a single space with no leading or trailing spaces. For example, "Hello World", "HELLO", "hello world hello world" are all sentences. Words consist of only uppercase and lowercase English letters.

    + +

    Two sentences sentence1 and sentence2 are similar if it is possible to insert an arbitrary sentence (possibly empty) inside one of these sentences such that the two sentences become equal. For example, sentence1 = "Hello my name is Jane" and sentence2 = "Hello Jane" can be made equal by inserting "my name is" between "Hello" and "Jane" in sentence2.

    + +

    Given two sentences sentence1 and sentence2, return true if sentence1 and sentence2 are similar. Otherwise, return false.

    + + +

    Example 1:

    + +
    +Input: sentence1 = "My name is Haley", sentence2 = "My Haley"
    +Output: true
    +Explanation: sentence2 can be turned to sentence1 by inserting "name is" between "My" and "Haley".
    +
    + +

    Example 2:

    + +
    +Input: sentence1 = "of", sentence2 = "A lot of words"
    +Output: false
    +Explanation: No single sentence can be inserted inside one of the sentences to make it equal to the other.
    +
    + +

    Example 3:

    + +
    +Input: sentence1 = "Eating right now", sentence2 = "Eating"
    +Output: true
    +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:

    + +
      +
    • 1 <= sentence1.length, sentence2.length <= 100
    • +
    • sentence1 and sentence2 consist of lowercase and uppercase English letters and spaces.
    • +
    • The words in sentence1 and sentence2 are separated by a single space.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +One way to look at it is to find one sentence as a concatenation of a prefix and suffix from the other sentence. +
    + +
    +Hint 2 +Get the longest common prefix between them and the longest common suffix. +
    diff --git a/problems/truncate-sentence/README.md b/problems/truncate-sentence/README.md new file mode 100644 index 000000000..facb980f3 --- /dev/null +++ b/problems/truncate-sentence/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../maximum-number-of-groups-getting-fresh-donuts "Maximum Number of Groups Getting Fresh Donuts") + +[Next>](../finding-the-users-active-minutes "Finding the Users Active Minutes") + +## [1816. Truncate Sentence (Easy)](https://leetcode.com/problems/truncate-sentence "截断句子") + +

    A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of only uppercase and lowercase English letters (no punctuation).

    + +
      +
    • For example, "Hello World", "HELLO", and "hello world hello world" are all sentences.
    • +
    + +

    You are given a sentence s​​​​​​ and an integer k​​​​​​. You want to truncate s​​​​​​ such that it contains only the first k​​​​​​ words. Return s​​​​​​ after truncating it.

    + + +

    Example 1:

    + +
    +Input: s = "Hello how are you Contestant", k = 4
    +Output: "Hello how are you"
    +Explanation:
    +The words in s are ["Hello", "how" "are", "you", "Contestant"].
    +The first 4 words are ["Hello", "how", "are", "you"].
    +Hence, you should return "Hello how are you".
    +
    + +

    Example 2:

    + +
    +Input: s = "What is the solution to this problem", k = 4
    +Output: "What is the solution"
    +Explanation:
    +The words in s are ["What", "is" "the", "solution", "to", "this", "problem"].
    +The first 4 words are ["What", "is", "the", "solution"].
    +Hence, you should return "What is the solution".
    + +

    Example 3:

    + +
    +Input: s = "chopper is not a tanuki", k = 5
    +Output: "chopper is not a tanuki"
    +
    + + +

    Constraints:

    + +
      +
    • 1 <= s.length <= 500
    • +
    • k is in the range [1, the number of words in s].
    • +
    • s consist of only lowercase and uppercase English letters and spaces.
    • +
    • The words in s are separated by a single space.
    • +
    • There are no leading or trailing spaces.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +It's easier to solve this problem on an array of strings so parse the string to an array of words +
    + +
    +Hint 2 +After return the first k words as a sentence +
    diff --git a/problems/tweet-counts-per-frequency/README.md b/problems/tweet-counts-per-frequency/README.md index 5c1992a42..6fbe1b6ba 100644 --- a/problems/tweet-counts-per-frequency/README.md +++ b/problems/tweet-counts-per-frequency/README.md @@ -11,20 +11,30 @@ ## [1348. Tweet Counts Per Frequency (Medium)](https://leetcode.com/problems/tweet-counts-per-frequency "推文计数") -

    Implement the class TweetCounts that supports two methods:

    +

    A social media company is trying to monitor activity on their site by analyzing the number of tweets that occur in select periods of time. These periods can be partitioned into smaller time chunks based on a certain frequency (every minute, hour, or day).

    -

    1. recordTweet(string tweetName, int time)

    +

    For example, the period [10, 10000] (in seconds) would be partitioned into the following time chunks with these frequencies:

      -
    • Stores the tweetName at the recorded time (in seconds).
    • +
    • Every minute (60-second chunks): [10,69], [70,129], [130,189], ..., [9970,10000]
    • +
    • Every hour (3600-second chunks): [10,3609], [3610,7209], [7210,10000]
    • +
    • Every day (86400-second chunks): [10,10000]
    -

    2. getTweetCountsPerFrequency(string freq, string tweetName, int startTime, int endTime)

    +

    Notice that the last chunk may be shorter than the specified frequency's chunk size and will always end with the end time of the period (10000 in the above example).

    + +

    Design and implement an API to help the company with their analysis.

    + +

    Implement the TweetCounts class:

      -
    • Returns the total number of occurrences for the given tweetName per minute, hour, or day (depending on freq) starting from the startTime (in seconds) and ending at the endTime (in seconds).
    • -
    • freq is always minute, hour or day, representing the time interval to get the total number of occurrences for the given tweetName.
    • -
    • The first time interval always starts from the startTime, so the time intervals are [startTime, startTime + delta*1>, [startTime + delta*1, startTime + delta*2>, [startTime + delta*2, startTime + delta*3>, ... , [startTime + delta*i, min(startTime + delta*(i+1), endTime + 1)> for some non-negative number i and delta (which depends on freq).
    • +
    • TweetCounts() Initializes the TweetCounts object.
    • +
    • void recordTweet(String tweetName, int time) Stores the tweetName at the recorded time (in seconds).
    • +
    • List<Integer> getTweetCountsPerFrequency(String freq, String tweetName, int startTime, int endTime) Returns a list of integers representing the number of tweets with tweetName in each time chunk for the given period of time [startTime, endTime] (in seconds) and frequency freq. +
        +
      • freq is one of "minute", "hour", or "day" representing a frequency of every minute, hour, or day respectively.
      • +
      +
    @@ -40,22 +50,22 @@ Explanation TweetCounts tweetCounts = new TweetCounts(); -tweetCounts.recordTweet("tweet3", 0); -tweetCounts.recordTweet("tweet3", 60); -tweetCounts.recordTweet("tweet3", 10); // All tweets correspond to "tweet3" with recorded times at 0, 10 and 60. -tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 59); // return [2]. The frequency is per minute (60 seconds), so there is one interval of time: 1) [0, 60> - > 2 tweets. -tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 60); // return [2, 1]. The frequency is per minute (60 seconds), so there are two intervals of time: 1) [0, 60> - > 2 tweets, and 2) [60,61> - > 1 tweet. -tweetCounts.recordTweet("tweet3", 120); // All tweets correspond to "tweet3" with recorded times at 0, 10, 60 and 120. -tweetCounts.getTweetCountsPerFrequency("hour", "tweet3", 0, 210); // return [4]. The frequency is per hour (3600 seconds), so there is one interval of time: 1) [0, 211> - > 4 tweets. +tweetCounts.recordTweet("tweet3", 0); // New tweet "tweet3" at time 0 +tweetCounts.recordTweet("tweet3", 60); // New tweet "tweet3" at time 60 +tweetCounts.recordTweet("tweet3", 10); // New tweet "tweet3" at time 10 +tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 59); // return [2]; chunk [0,59] had 2 tweets +tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 60); // return [2,1]; chunk [0,59] had 2 tweets, chunk [60,60] had 1 tweet +tweetCounts.recordTweet("tweet3", 120); // New tweet "tweet3" at time 120 +tweetCounts.getTweetCountsPerFrequency("hour", "tweet3", 0, 210); // return [4]; chunk [0,210] had 4 tweets

    Constraints:

    ### Related Topics diff --git a/problems/utf-8-validation/README.md b/problems/utf-8-validation/README.md index d02dcde1e..2f1d30269 100644 --- a/problems/utf-8-validation/README.md +++ b/problems/utf-8-validation/README.md @@ -11,50 +11,57 @@ ## [393. UTF-8 Validation (Medium)](https://leetcode.com/problems/utf-8-validation "UTF-8 编码验证") -

    A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules:

    +

    Given an integer array data representing the data, return whether it is a valid UTF-8 encoding.

    + +

    A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules:

    +
      -
    1. For 1-byte character, the first bit is a 0, followed by its unicode code.
    2. -
    3. For n-bytes character, the first n-bits are all one's, the n+1 bit is 0, followed by n-1 bytes with most significant 2 bits being 10.
    4. +
    5. For a 1-byte character, the first bit is a 0, followed by its Unicode code.
    6. +
    7. For an n-bytes character, the first n bits are all one's, the n + 1 bit is 0, followed by n - 1 bytes with the most significant 2 bits being 10.
    +

    This is how the UTF-8 encoding would work:

    -
     Char. number range | UTF-8 octet sequence
    +
    + Char. number range | UTF-8 octet sequence
     (hexadecimal) | (binary)
     --------------------+---------------------------------------------
     0000 0000-0000 007F | 0xxxxxxx
     0000 0080-0000 07FF | 110xxxxx 10xxxxxx
     0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
    - 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    -
    -

    -Given an array of integers representing the data, return whether it is a valid utf-8 encoding. -

    -

    -Note:
    -The input is an array of integers. Only the least significant 8 bits of each integer is used to store the data. This means each integer represents only 1 byte of data. -

    - -

    -Example 1: -

    -data = [197, 130, 1], which represents the octet sequence: 11000101 10000010 00000001.
    + 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    +
    + +

    Note: The input is an array of integers. Only the least significant 8 bits of each integer is used to store the data. This means each integer represents only 1 byte of data.

    -Return true. + +

    Example 1:

    + +
    +Input: data = [197,130,1]
    +Output: true
    +Explanation: data represents the octet sequence: 11000101 10000010 00000001.
     It is a valid utf-8 encoding for a 2-bytes character followed by a 1-byte character.
     
    -

    -

    -Example 2: -

    -data = [235, 140, 4], which represented the octet sequence: 11101011 10001100 00000100.
    +

    Example 2:

    -Return false. -The first 3 bits are all one's and the 4th bit is 0 means it is a 3-bytes character. -The next byte is a continuation byte which starts with 10 and that's correct. +
    +Input: data = [235,140,4]
    +Output: false
    +Explanation: data represented the octet sequence: 11101011 10001100 00000100.
    +The first 3 bits are all one's and the 4th bit is 0 means it is a 3-bytes character.
    +The next byte is a continuation byte which starts with 10 and that's correct.
     But the second continuation byte does not start with 10, so it is invalid.
     
    -

    + + +

    Constraints:

    + +
      +
    • 1 <= data.length <= 2 * 104
    • +
    • 0 <= data[i] <= 255
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/vowel-spellchecker/README.md b/problems/vowel-spellchecker/README.md index fd93b6fab..c8dc8baa3 100644 --- a/problems/vowel-spellchecker/README.md +++ b/problems/vowel-spellchecker/README.md @@ -11,7 +11,7 @@ ## [966. Vowel Spellchecker (Medium)](https://leetcode.com/problems/vowel-spellchecker "元音拼写检查器") -

    Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word.

    +

    Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word.

    For a given query word, the spell checker handles two categories of spelling mistakes:

    @@ -23,7 +23,7 @@
  • Example: wordlist = ["yellow"], query = "yellow": correct = "yellow"
  • -
  • Vowel Errors: If after replacing the vowels ('a', 'e', 'i', 'o', 'u') of the query word with any vowel individually, it matches a word in the wordlist (case-insensitive), then the query word is returned with the same case as the match in the wordlist. +
  • Vowel Errors: If after replacing the vowels ('a', 'e', 'i', 'o', 'u') of the query word with any vowel individually, it matches a word in the wordlist (case-insensitive), then the query word is returned with the same case as the match in the wordlist.
    • Example: wordlist = ["YellOw"], query = "yollow": correct = "YellOw"
    • Example: wordlist = ["YellOw"], query = "yeellow": correct = "" (no match)
    • @@ -41,26 +41,23 @@
    • If the query has no matches in the wordlist, you should return the empty string.
    -

    Given some queries, return a list of words answer, where answer[i] is the correct word for query = queries[i].

    +

    Given some queries, return a list of words answer, where answer[i] is the correct word for query = queries[i].

    -

    Example 1:

    - -
    -Input: wordlist = ["KiTe","kite","hare","Hare"], queries = ["kite","Kite","KiTe","Hare","HARE","Hear","hear","keti","keet","keto"]
    -Output: ["kite","KiTe","KiTe","Hare","hare","","","KiTe","","KiTe"]
    - +
    Input: wordlist = ["KiTe","kite","hare","Hare"], queries = ["kite","Kite","KiTe","Hare","HARE","Hear","hear","keti","keet","keto"]
    +Output: ["kite","KiTe","KiTe","Hare","hare","","","KiTe","","KiTe"]
    +

    Example 2:

    +
    Input: wordlist = ["yellow"], queries = ["YellOw"]
    +Output: ["yellow"]
    +
    - -

    Note:

    +

    Constraints:

      -
    • 1 <= wordlist.length <= 5000
    • -
    • 1 <= queries.length <= 5000
    • -
    • 1 <= wordlist[i].length <= 7
    • -
    • 1 <= queries[i].length <= 7
    • -
    • All strings in wordlist and queries consist only of english letters.
    • +
    • 1 <= wordlist.length, queries.length <= 5000
    • +
    • 1 <= wordlist[i].length, queries[i].length <= 7
    • +
    • wordlist[i] and queries[i] consist only of only English letters.
    ### Related Topics diff --git a/problems/water-and-jug-problem/README.md b/problems/water-and-jug-problem/README.md index f9ace2243..502c16158 100644 --- a/problems/water-and-jug-problem/README.md +++ b/problems/water-and-jug-problem/README.md @@ -11,38 +11,46 @@ ## [365. Water and Jug Problem (Medium)](https://leetcode.com/problems/water-and-jug-problem "水壶问题") -

    You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly z litres using these two jugs.

    +

    You are given two jugs with capacities jug1Capacity and jug2Capacity liters. There is an infinite amount of water supply available. Determine whether it is possible to measure exactly targetCapacity liters using these two jugs.

    -

    If z liters of water is measurable, you must have z liters of water contained within one or both buckets by the end.

    +

    If targetCapacity liters of water are measurable, you must have targetCapacity liters of water contained within one or both buckets by the end.

    Operations allowed:

      -
    • Fill any of the jugs completely with water.
    • +
    • Fill any of the jugs with water.
    • Empty any of the jugs.
    • -
    • Pour water from one jug into another till the other jug is completely full or the first jug itself is empty.
    • +
    • Pour water from one jug into another till the other jug is completely full, or the first jug itself is empty.
    -

    Example 1: (From the famous "Die Hard" example)

    + +

    Example 1:

    + +
    +Input: jug1Capacity = 3, jug2Capacity = 5, targetCapacity = 4
    +Output: true
    +Explanation: The famous Die Hard example 
    +
    + +

    Example 2:

    -Input: x = 3, y = 5, z = 4
    -Output: True
    +Input: jug1Capacity = 2, jug2Capacity = 6, targetCapacity = 5
    +Output: false
     
    -

    Example 2:

    +

    Example 3:

    -Input: x = 2, y = 6, z = 5
    -Output: False
    +Input: jug1Capacity = 1, jug2Capacity = 2, targetCapacity = 3
    +Output: true
     
    +

    Constraints:

      -
    • 0 <= x <= 10^6
    • -
    • 0 <= y <= 10^6
    • -
    • 0 <= z <= 10^6
    • +
    • 1 <= jug1Capacity, jug2Capacity, targetCapacity <= 106
    ### Related Topics diff --git a/problems/wiggle-subsequence/README.md b/problems/wiggle-subsequence/README.md index 73fab926b..6a744d8d1 100644 --- a/problems/wiggle-subsequence/README.md +++ b/problems/wiggle-subsequence/README.md @@ -11,16 +11,16 @@ ## [376. Wiggle Subsequence (Medium)](https://leetcode.com/problems/wiggle-subsequence "摆动序列") -

    Given an integer array nums, return the length of the longest wiggle sequence.

    - -

    A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence.

    +

    A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with two or fewer elements is trivially a wiggle sequence.

      -
    • For example, [1, 7, 4, 9, 2, 5] is a wiggle sequence because the differences (6, -3, 5, -7, 3) are alternately positive and negative.
    • -
    • In contrast, [1, 4, 7, 2, 5] and [1, 7, 4, 5, 5] are not wiggle sequences, the first because its first two differences are positive and the second because its last difference is zero.
    • +
    • For example, [1, 7, 4, 9, 2, 5] is a wiggle sequence because the differences (6, -3, 5, -7, 3) alternate between positive and negative.
    • +
    • In contrast, [1, 4, 7, 2, 5] and [1, 7, 4, 5, 5] are not wiggle sequences. The first is not because its first two differences are positive, and the second is not because its last difference is zero.
    -

    A subsequence is obtained by deleting some elements (eventually, also zero) from the original sequence, leaving the remaining elements in their original order.

    +

    A subsequence is obtained by deleting some elements (possibly zero) from the original sequence, leaving the remaining elements in their original order.

    + +

    Given an integer array nums, return the length of the longest wiggle subsequence of nums.

    Example 1:

    @@ -28,7 +28,7 @@
     Input: nums = [1,7,4,9,2,5]
     Output: 6
    -Explanation: The entire sequence is a wiggle sequence.
    +Explanation: The entire sequence is a wiggle sequence with differences (6, -3, 5, -7, 3).
     

    Example 2:

    @@ -36,7 +36,8 @@
     Input: nums = [1,17,5,10,13,15,10,5,16,8]
     Output: 7
    -Explanation: There are several subsequences that achieve this length. One is [1,17,10,13,10,16,8].
    +Explanation: There are several subsequences that achieve this length.
    +One is [1, 17, 10, 13, 10, 16, 8] with differences (16, -7, 3, -3, 6, -8).
     

    Example 3:

    diff --git a/problems/word-search/README.md b/problems/word-search/README.md index 7d0419bff..5435a6bf0 100644 --- a/problems/word-search/README.md +++ b/problems/word-search/README.md @@ -15,8 +15,6 @@

    The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.

    -

    Note: There will be some test cases with a board or a word larger than constraints to test if your solution is using pruning.

    -

    Example 1:

    @@ -50,6 +48,9 @@
  • board and word consists of only lowercase and uppercase English letters.
  • + +

    Follow up: Could you use search pruning to make your solution faster with a larger board?

    + ### Related Topics [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/readme/1-300.md b/readme/1-300.md index c557a377e..441dc0d20 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -157,7 +157,7 @@ LeetCode Problems' Solutions | 77 | [Combinations](https://leetcode.com/problems/combinations "组合") | [Go](../problems/combinations) | Medium | | 78 | [Subsets](https://leetcode.com/problems/subsets "子集") | [Go](../problems/subsets) | Medium | | 79 | [Word Search](https://leetcode.com/problems/word-search "单词搜索") | [Go](../problems/word-search) | Medium | -| 80 | [Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii "删除排序数组中的重复项 II") | [Go](../problems/remove-duplicates-from-sorted-array-ii) | Medium | +| 80 | [Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii "删除有序数组中的重复项 II") | [Go](../problems/remove-duplicates-from-sorted-array-ii) | Medium | | 81 | [Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii "搜索旋转排序数组 II") | [Go](../problems/search-in-rotated-sorted-array-ii) | Medium | | 82 | [Remove Duplicates from Sorted List II](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii "删除排序链表中的重复元素 II") | [Go](../problems/remove-duplicates-from-sorted-list-ii) | Medium | | 83 | [Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list "删除排序链表中的重复元素") | [Go](../problems/remove-duplicates-from-sorted-list) | Easy | @@ -174,7 +174,7 @@ LeetCode Problems' Solutions | 94 | [Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal "二叉树的中序遍历") | [Go](../problems/binary-tree-inorder-traversal) | Medium | | 95 | [Unique Binary Search Trees II](https://leetcode.com/problems/unique-binary-search-trees-ii "不同的二叉搜索树 II") | [Go](../problems/unique-binary-search-trees-ii) | Medium | | 96 | [Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees "不同的二叉搜索树") | [Go](../problems/unique-binary-search-trees) | Medium | -| 97 | [Interleaving String](https://leetcode.com/problems/interleaving-string "交错字符串") | [Go](../problems/interleaving-string) | Hard | +| 97 | [Interleaving String](https://leetcode.com/problems/interleaving-string "交错字符串") | [Go](../problems/interleaving-string) | Medium | | 98 | [Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree "验证二叉搜索树") | [Go](../problems/validate-binary-search-tree) | Medium | | 99 | [Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree "恢复二叉搜索树") | [Go](../problems/recover-binary-search-tree) | Hard | | 100 | [Same Tree](https://leetcode.com/problems/same-tree "相同的树") | [Go](../problems/same-tree) | Easy | diff --git a/readme/301-600.md b/readme/301-600.md index b8b6014d0..f0d313bb3 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -233,7 +233,7 @@ LeetCode Problems' Solutions | 453 | [Minimum Moves to Equal Array Elements](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小操作次数使数组元素相等") | [Go](../problems/minimum-moves-to-equal-array-elements) | Easy | | 454 | [4Sum II](https://leetcode.com/problems/4sum-ii "四数相加 II") | [Go](../problems/4sum-ii) | Medium | | 455 | [Assign Cookies](https://leetcode.com/problems/assign-cookies "分发饼干") | [Go](../problems/assign-cookies) | Easy | -| 456 | [132 Pattern](https://leetcode.com/problems/132-pattern "132模式") | [Go](../problems/132-pattern) | Medium | +| 456 | [132 Pattern](https://leetcode.com/problems/132-pattern "132 模式") | [Go](../problems/132-pattern) | Medium | | 457 | [Circular Array Loop](https://leetcode.com/problems/circular-array-loop "环形数组是否存在循环") | [Go](../problems/circular-array-loop) | Medium | | 458 | [Poor Pigs](https://leetcode.com/problems/poor-pigs "可怜的小猪") | [Go](../problems/poor-pigs) | Hard | | 459 | [Repeated Substring Pattern](https://leetcode.com/problems/repeated-substring-pattern "重复的子字符串") | [Go](../problems/repeated-substring-pattern) | Easy | diff --git a/tag/README.md b/tag/README.md index c51022ce6..154ccffc3 100644 --- a/tag/README.md +++ b/tag/README.md @@ -16,11 +16,11 @@ | 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | -| 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | -| 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | +| 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | +| 17 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 18 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 19 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 20 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 21 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 22 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | -| 23 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 24 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | +| 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | diff --git a/tag/array/README.md b/tag/array/README.md index 6917adf62..598d964a1 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1779 | [找到最近的有相同 X 或 Y 坐标的点](../../problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | [[数组](../array/README.md)] | Easy | | 1773 | [统计匹配检索规则的物品数量](../../problems/count-items-matching-a-rule) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | @@ -287,7 +289,7 @@ | 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard | | 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 80 | [删除排序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 80 | [删除有序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index bb86afc6e..981cc07af 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 3f0ef6a26..ab6bf917e 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index 7af1d3fff..14091cf0c 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,64 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | -| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | -| 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy | -| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium | -| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | -| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | -| 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | -| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium | -| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] | Hard | -| 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[设计](../design/README.md)] | Hard | -| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 716 | [最大栈](../../problems/max-stack) 🔒 | [[设计](../design/README.md)] | Easy | -| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | -| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | -| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | -| 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[设计](../design/README.md)] | Hard | -| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] | Easy | -| 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] | Hard | -| 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard | -| 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] | Hard | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] | Medium | -| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 348 | [设计井字棋](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] | Medium | -| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | -| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | -| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | -| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | -| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] | Medium | -| 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] | Medium | -| 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] | Medium | -| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | -| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 785185547..0956b9622 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1787 | [使所有区间的异或结果为零](../../problems/make-the-xor-of-all-segments-equal-to-zero) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -244,7 +245,7 @@ | 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/graph/README.md b/tag/graph/README.md index 22929b33d..089e192cd 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1791 | [找出星型图的中心节点](../../problems/find-center-of-star-graph) | [[图](../graph/README.md)] | Medium | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1782 | [统计点对的数目](../../problems/count-pairs-of-nodes) | [[图](../graph/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index d7f88e58d..23e2e9822 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 1798 | [你能构造出连续值的最大数目](../../problems/maximum-number-of-consecutive-values-you-can-make) | [[贪心算法](../greedy/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index e059ec8c0..893f7a670 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1817 | [查找用户活跃分钟数](../../problems/finding-the-users-active-minutes) | [[哈希表](../hash-table/README.md)] | Medium | +| 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1807 | [替换字符串中的括号内容](../../problems/evaluate-the-bracket-pairs-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1781 | [所有子字符串美丽值之和](../../problems/sum-of-beauty-of-all-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index a51615a33..39b134930 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,46 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 1792 | [最大平均通过率](../../problems/maximum-average-pass-ratio) | [[堆](../heap/README.md)] | Medium | -| 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | -| 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | -| 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 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 | -| 882 | [细分图中的可到达结点](../../problems/reachable-nodes-in-subdivided-graph) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[堆](../heap/README.md)] | Hard | -| 818 | [赛车](../../problems/race-car) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | -| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | -| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | -| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[堆](../heap/README.md)] | Medium | -| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 313 | [超级丑数](../../problems/super-ugly-number) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | -| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | -| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[堆](../heap/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/math/README.md b/tag/math/README.md index 98b0edc3b..e0413d1ad 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数学](../math/README.md)] | Hard | +| 1808 | [好因子的最大数目](../../problems/maximize-number-of-nice-divisors) | [[数学](../math/README.md)] | Hard | | 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1776 | [车队 II](../../problems/car-fleet-ii) | [[数学](../math/README.md)] | Hard | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/memoization/README.md b/tag/memoization/README.md index 2c6a5dffd..f418d566c 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -9,4 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 85faedb8e..52afd5989 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,17 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 0c9155aea..8922feba8 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,14 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | -| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | -| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | -| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | -| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 1989c8da1..42f90d3a9 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,42 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | -| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[递归](../recursion/README.md)] | Medium | -| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | -| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | -| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | -| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | -| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index b34d04e3d..bdf264168 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,19 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[线段树](../segment-tree/README.md)] | Hard | -| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Hard | -| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index ee49220e1..fbbfc5182 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,30 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 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 | -| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[Sliding Window](../sliding-window/README.md)] | Hard | -| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index 238b0b4da..e86c8bc67 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -47,7 +47,7 @@ | 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | | 503 | [下一个更大元素 II](../../problems/next-greater-element-ii) | [[栈](../stack/README.md)] | Medium | | 496 | [下一个更大元素 I](../../problems/next-greater-element-i) | [[栈](../stack/README.md)] | Easy | -| 456 | [132模式](../../problems/132-pattern) | [[栈](../stack/README.md)] | Medium | +| 456 | [132 模式](../../problems/132-pattern) | [[栈](../stack/README.md)] | Medium | | 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index 49673dbd2..4be21cb8c 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1816 | [截断句子](../../problems/truncate-sentence) | [[字符串](../string/README.md)] | Easy | +| 1813 | [句子相似性 III](../../problems/sentence-similarity-iii) | [[字符串](../string/README.md)] | Medium | +| 1812 | [判断国际象棋棋盘中一个格子的颜色](../../problems/determine-color-of-a-chessboard-square) | [[字符串](../string/README.md)] | Easy | +| 1807 | [替换字符串中的括号内容](../../problems/evaluate-the-bracket-pairs-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1805 | [字符串中不同整数的数目](../../problems/number-of-different-integers-in-a-string) | [[字符串](../string/README.md)] | Easy | +| 1804 | [Implement Trie II (Prefix Tree)](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | | 1796 | [字符串中第二大的数字](../../problems/second-largest-digit-in-a-string) | [[字符串](../string/README.md)] | Easy | | 1794 | [Count Pairs of Equal Substrings With Minimum Difference](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1790 | [仅执行一次字符串交换能否使两个字符串相等](../../problems/check-if-one-string-swap-can-make-strings-equal) | [[字符串](../string/README.md)] | Easy | @@ -204,7 +210,7 @@ | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 93 | [复原 IP 地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/tags.json b/tag/tags.json index af38a6919..10fc56aa0 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -74,16 +74,16 @@ "Slug": "design", "TranslatedName": "设计" }, - { - "Name": "Bit Manipulation", - "Slug": "bit-manipulation", - "TranslatedName": "位运算" - }, { "Name": "Graph", "Slug": "graph", "TranslatedName": "图" }, + { + "Name": "Bit Manipulation", + "Slug": "bit-manipulation", + "TranslatedName": "位运算" + }, { "Name": "Heap", "Slug": "heap", @@ -109,16 +109,16 @@ "Slug": "sliding-window", "TranslatedName": "Sliding Window" }, - { - "Name": "Divide and Conquer", - "Slug": "divide-and-conquer", - "TranslatedName": "分治算法" - }, { "Name": "Trie", "Slug": "trie", "TranslatedName": "字典树" }, + { + "Name": "Divide and Conquer", + "Slug": "divide-and-conquer", + "TranslatedName": "分治算法" + }, { "Name": "Segment Tree", "Slug": "segment-tree", diff --git a/tag/trie/README.md b/tag/trie/README.md index 7cb89a16a..1421c18eb 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1804 | [Implement Trie II (Prefix Tree)](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | | 1803 | [统计异或值在范围内的数对有多少](../../problems/count-pairs-with-xor-in-a-range) | [[字典树](../trie/README.md)] | Hard | | 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Hard | | 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 26051df30..72d139e04 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,77 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1800 | [最大升序子数组和](../../problems/maximum-ascending-subarray-sum) | [[双指针](../two-pointers/README.md)] | Easy | -| 1750 | [删除字符串两端相同字符后的最短长度](../../problems/minimum-length-of-string-after-deleting-similar-ends) | [[双指针](../two-pointers/README.md)] | Medium | -| 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1695 | [删除子数组的最大得分](../../problems/maximum-erasure-value) | [[双指针](../two-pointers/README.md)] | Medium | -| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | -| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)] | Medium | -| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 986 | [区间列表的交集](../../problems/interval-list-intersections) | [[双指针](../two-pointers/README.md)] | Medium | -| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[双指针](../two-pointers/README.md)] | Medium | -| 904 | [水果成篮](../../problems/fruit-into-baskets) | [[双指针](../two-pointers/README.md)] | Medium | -| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[双指针](../two-pointers/README.md)] | Medium | -| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 828 | [统计子串中的唯一字符](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[双指针](../two-pointers/README.md)] | Hard | -| 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[双指针](../two-pointers/README.md)] | Medium | -| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[双指针](../two-pointers/README.md)] | Medium | -| 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/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 | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 80 | [删除排序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 26 | [删除有序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 19 | [删除链表的倒数第 N 个结点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | From e984c6b700366125429547c80fc054c4a9111e31 Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 6 Apr 2021 11:36:13 +0800 Subject: [PATCH 2/2] A: tag --- tag/design/README.md | 61 +++++++++++++++++++++++++++++ tag/heap/README.md | 44 +++++++++++++++++++++ tag/memoization/README.md | 1 + tag/ordered-map/README.md | 14 +++++++ tag/queue/README.md | 11 ++++++ tag/recursion/README.md | 39 +++++++++++++++++++ tag/segment-tree/README.md | 16 ++++++++ tag/sliding-window/README.md | 27 +++++++++++++ tag/two-pointers/README.md | 74 ++++++++++++++++++++++++++++++++++++ 9 files changed, 287 insertions(+) diff --git a/tag/design/README.md b/tag/design/README.md index 14091cf0c..7af1d3fff 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,3 +9,64 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | +| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | +| 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy | +| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium | +| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | +| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | +| 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | +| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium | +| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] | Hard | +| 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[设计](../design/README.md)] | Hard | +| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 716 | [最大栈](../../problems/max-stack) 🔒 | [[设计](../design/README.md)] | Easy | +| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | +| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | +| 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[设计](../design/README.md)] | Hard | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] | Easy | +| 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] | Hard | +| 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard | +| 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] | Hard | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] | Medium | +| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 348 | [设计井字棋](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] | Medium | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | +| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | +| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | +| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] | Medium | +| 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] | Medium | +| 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] | Medium | +| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index 39b134930..03cd2ce78 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,3 +9,47 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 1792 | [最大平均通过率](../../problems/maximum-average-pass-ratio) | [[堆](../heap/README.md)] | Medium | +| 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | +| 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | +| 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 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 | +| 882 | [细分图中的可到达结点](../../problems/reachable-nodes-in-subdivided-graph) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[堆](../heap/README.md)] | Hard | +| 818 | [赛车](../../problems/race-car) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[堆](../heap/README.md)] | Medium | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 313 | [超级丑数](../../problems/super-ugly-number) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | +| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | +| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[堆](../heap/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/memoization/README.md b/tag/memoization/README.md index f418d566c..2c6a5dffd 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -9,3 +9,4 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 52afd5989..85faedb8e 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,3 +9,17 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 8922feba8..0c9155aea 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,3 +9,14 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | +| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | +| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 42f90d3a9..1989c8da1 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,3 +9,42 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[递归](../recursion/README.md)] | Medium | +| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | +| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | +| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index bdf264168..b34d04e3d 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,3 +9,19 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[线段树](../segment-tree/README.md)] | Hard | +| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Hard | +| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Medium | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index fbbfc5182..ee49220e1 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,3 +9,30 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 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 | +| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[Sliding Window](../sliding-window/README.md)] | Hard | +| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 72d139e04..80e3c1097 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,3 +9,77 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1800 | [最大升序子数组和](../../problems/maximum-ascending-subarray-sum) | [[双指针](../two-pointers/README.md)] | Easy | +| 1750 | [删除字符串两端相同字符后的最短长度](../../problems/minimum-length-of-string-after-deleting-similar-ends) | [[双指针](../two-pointers/README.md)] | Medium | +| 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1695 | [删除子数组的最大得分](../../problems/maximum-erasure-value) | [[双指针](../two-pointers/README.md)] | Medium | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)] | Medium | +| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 986 | [区间列表的交集](../../problems/interval-list-intersections) | [[双指针](../two-pointers/README.md)] | Medium | +| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[双指针](../two-pointers/README.md)] | Medium | +| 904 | [水果成篮](../../problems/fruit-into-baskets) | [[双指针](../two-pointers/README.md)] | Medium | +| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[双指针](../two-pointers/README.md)] | Medium | +| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 828 | [统计子串中的唯一字符](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[双指针](../two-pointers/README.md)] | Hard | +| 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[双指针](../two-pointers/README.md)] | Medium | +| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[双指针](../two-pointers/README.md)] | Medium | +| 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/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 | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 80 | [删除有序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 26 | [删除有序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 19 | [删除链表的倒数第 N 个结点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium |

    AltStyle によって変換されたページ (->オリジナル) /