diff --git a/solution/1200-1299/1249.Minimum Remove to Make Valid Parentheses/README_EN.md b/solution/1200-1299/1249.Minimum Remove to Make Valid Parentheses/README_EN.md index 87b616d7a8cc4..a10958d1e865d 100644 --- a/solution/1200-1299/1249.Minimum Remove to Make Valid Parentheses/README_EN.md +++ b/solution/1200-1299/1249.Minimum Remove to Make Valid Parentheses/README_EN.md @@ -47,7 +47,7 @@
1 <= s.length <= 105
s[i]
is either'('
, ')'
, or lowercase English letter.
s[i]
is either '('
, ')'
, or lowercase English letter.1 <= str.length <= 1000
+Follow up: Let's assume, for the sake of simplifying analysis, that concatenating strings is a constant time operation
O(1)
. With this assumption in mind, can you write an algorithm with a runtime complexity of O(log n)
?
+
## Solutions
### Solution 1
diff --git a/solution/2800-2899/2821.Delay the Resolution of Each Promise/README_EN.md b/solution/2800-2899/2821.Delay the Resolution of Each Promise/README_EN.md
index e6487bcca5f77..f3f6437b12b37 100644
--- a/solution/2800-2899/2821.Delay the Resolution of Each Promise/README_EN.md
+++ b/solution/2800-2899/2821.Delay the Resolution of Each Promise/README_EN.md
@@ -10,10 +10,12 @@
functions
is an array of functions that return promises.ms
represents the delay duration in milliseconds. It determines the amount of time to wait before resolving each promise in the new array.ms
represents the delay duration in milliseconds. It determines the amount of time to wait before resolving or rejecting each promise in the new array.Each function in the new array should return a promise that resolves after a delay of ms
milliseconds, preserving the order of the original functions
array. The delayAll
function should ensure that each promise from functions
is executed with a delay, forming the new array of functions returning delayed promises.
Each function in the new array should return a promise that resolves or rejects after an additional delay of ms
milliseconds, preserving the order of the original functions
array.
The delayAll
function should ensure that each promise from functions
is executed with a delay, forming the new array of functions returning delayed promises.
Example 1:
@@ -41,6 +43,18 @@ ms = 70 Explanation: The promises from the array would have resolved after 50 ms and 80 ms, but they were delayed by 70 ms, thus 50 ms + 70 ms = 120 ms and 80 ms + 70 ms = 150 ms. +Example 3:
+ ++Input: +functions = [ + () => new Promise((resolve, reject) => setTimeout(reject, 20)), + () => new Promise((resolve, reject) => setTimeout(reject, 100)) +], +ms = 30 +Output: [50,130] ++
Constraints:
diff --git a/solution/3000-3099/3096.Minimum Levels to Gain More Points/README_EN.md b/solution/3000-3099/3096.Minimum Levels to Gain More Points/README_EN.md index a7e8166129d74..3b8784eef6f28 100644 --- a/solution/3000-3099/3096.Minimum Levels to Gain More Points/README_EN.md +++ b/solution/3000-3099/3096.Minimum Levels to Gain More Points/README_EN.md @@ -8,13 +8,13 @@You are given a binary array possible
of length n
.
Danielchandg and Bob are playing a game that consists of n
levels. Some of the levels in the game are impossible to clear while others can always be cleared. In particular, if possible[i] == 0
, then the ith
level is impossible to clear for both the players. A player gains 1
point on clearing a level and loses 1
point if the player fails to clear it.
Alice and Bob are playing a game that consists of n
levels. Some of the levels in the game are impossible to clear while others can always be cleared. In particular, if possible[i] == 0
, then the ith
level is impossible to clear for both the players. A player gains 1
point on clearing a level and loses 1
point if the player fails to clear it.
At the start of the game, Danielchandg will play some levels in the given order starting from the 0th
level, after which Bob will play for the rest of the levels.
At the start of the game, Alice will play some levels in the given order starting from the 0th
level, after which Bob will play for the rest of the levels.
Danielchandg wants to know the minimum number of levels he should play to gain more points than Bob, if both players play optimally to maximize their points.
+Alice wants to know the minimum number of levels she should play to gain more points than Bob, if both players play optimally to maximize their points.
-Return the minimum number of levels danielchandg should play to gain more points. If this is not possible, return -1
.
Return the minimum number of levels Alice should play to gain more points. If this is not possible, return -1
.
Note that each player must play at least 1
level.
Explanation:
-Let's look at all the levels that Danielchandg can play up to:
+Let's look at all the levels that Alice can play up to:
Danielchandg must play a minimum of 1 level to gain more points.
+Alice must play a minimum of 1 level to gain more points.
Example 2:
@@ -48,16 +48,16 @@Explanation:
-Let's look at all the levels that Danielchandg can play up to:
+Let's look at all the levels that Alice can play up to:
Danielchandg must play a minimum of 3 levels to gain more points.
+Alice must play a minimum of 3 levels to gain more points.
Example 3:
@@ -69,7 +69,7 @@Explanation:
-The only possible way is for both players to play 1 level each. Danielchandg plays level 0 and loses 1 point. Bob plays level 1 and loses 1 point. As both players have equal points, Danielchandg can't gain more points than Bob.
+The only possible way is for both players to play 1 level each. Alice plays level 0 and loses 1 point. Bob plays level 1 and loses 1 point. As both players have equal points, Alice can't gain more points than Bob.
diff --git a/solution/3100-3199/3112.Minimum Time to Visit Disappearing Nodes/README_EN.md b/solution/3100-3199/3112.Minimum Time to Visit Disappearing Nodes/README_EN.md index 672fe662c50a0..e22841a5d81e6 100644 --- a/solution/3100-3199/3112.Minimum Time to Visit Disappearing Nodes/README_EN.md +++ b/solution/3100-3199/3112.Minimum Time to Visit Disappearing Nodes/README_EN.md @@ -71,7 +71,7 @@
Constraints:
2 <= n <= 5 * 104
1 <= n <= 5 * 104
0 <= edges.length <= 105
edges[i] == [ui, vi, lengthi]
0 <= ui, vi <= n - 1
Table: Purchases
++---------------+------+ +| Column Name | Type | ++---------------+------+ +| user_id | int | +| purchase_date | date | +| amount_spend | int | ++---------------+------+ +(user_id, purchase_date, amount_spend) is the primary key (combination of columns with unique values) for this table. +purchase_date will range from November 1, 2023, to November 30, 2023, inclusive of both dates. +Each row contains user_id, purchase_date, and amount_spend. ++ +
Table: Users
++-------------+------+ +| Column Name | Type | ++-------------+------+ +| user_id | int | +| membership | enum | ++-------------+------+ +user_id is the primary key for this table. +membership is an ENUM (category) type of ('Standard', 'Premium', 'VIP'). +Each row of this table indicates the user_id, membership type. ++ +
Write a solution to calculate the total spending by Premium
and VIP
members on each Friday of every week in November 2023. If there are no purchases on a particular Friday by Premium
or VIP
members, it should be considered as 0
.
Return the result table ordered by week of the month, and membership
in ascending order.
The result format is in the following example.
+ ++
Example:
+ +Input:
+ +Purchases table:
+ +++---------+---------------+--------------+ +| user_id | purchase_date | amount_spend | ++---------+---------------+--------------+ +| 11 | 2023-11-03 | 1126 | +| 15 | 2023-11-10 | 7473 | +| 17 | 2023-11-17 | 2414 | +| 12 | 2023-11-24 | 9692 | +| 8 | 2023-11-24 | 5117 | +| 1 | 2023-11-24 | 5241 | +| 10 | 2023-11-22 | 8266 | +| 13 | 2023-11-21 | 12000 | ++---------+---------------+--------------+ ++ +
Users table:
+ +++---------+------------+ +| user_id | membership | ++---------+------------+ +| 11 | Premium | +| 15 | VIP | +| 17 | Standard | +| 12 | VIP | +| 8 | Premium | +| 1 | VIP | +| 10 | Standard | +| 13 | Premium | ++---------+------------+ ++ +
Output:
+ +++---------------+-------------+--------------+ +| week_of_month | membership | total_amount | ++---------------+-------------+--------------+ +| 1 | Premium | 1126 | +| 1 | VIP | 0 | +| 2 | Premium | 0 | +| 2 | VIP | 7473 | +| 3 | Premium | 0 | +| 3 | VIP | 0 | +| 4 | Premium | 5117 | +| 4 | VIP | 14933 | ++---------------+-------------+--------------+ ++ +
Explanation:
+ +Note: The output table is ordered by week_of_month and membership in ascending order.
+Table: Purchases
++---------------+------+ +| Column Name | Type | ++---------------+------+ +| user_id | int | +| purchase_date | date | +| amount_spend | int | ++---------------+------+ +(user_id, purchase_date, amount_spend) is the primary key (combination of columns with unique values) for this table. +purchase_date will range from November 1, 2023, to November 30, 2023, inclusive of both dates. +Each row contains user_id, purchase_date, and amount_spend. ++ +
Table: Users
++-------------+------+ +| Column Name | Type | ++-------------+------+ +| user_id | int | +| membership | enum | ++-------------+------+ +user_id is the primary key for this table. +membership is an ENUM (category) type of ('Standard', 'Premium', 'VIP'). +Each row of this table indicates the user_id, membership type. ++ +
Write a solution to calculate the total spending by Premium
and VIP
members on each Friday of every week in November 2023. If there are no purchases on a particular Friday by Premium
or VIP
members, it should be considered as 0
.
Return the result table ordered by week of the month, and membership
in ascending order.
The result format is in the following example.
+ ++
Example:
+ +Input:
+ +Purchases table:
+ +++---------+---------------+--------------+ +| user_id | purchase_date | amount_spend | ++---------+---------------+--------------+ +| 11 | 2023-11-03 | 1126 | +| 15 | 2023-11-10 | 7473 | +| 17 | 2023-11-17 | 2414 | +| 12 | 2023-11-24 | 9692 | +| 8 | 2023-11-24 | 5117 | +| 1 | 2023-11-24 | 5241 | +| 10 | 2023-11-22 | 8266 | +| 13 | 2023-11-21 | 12000 | ++---------+---------------+--------------+ ++ +
Users table:
+ +++---------+------------+ +| user_id | membership | ++---------+------------+ +| 11 | Premium | +| 15 | VIP | +| 17 | Standard | +| 12 | VIP | +| 8 | Premium | +| 1 | VIP | +| 10 | Standard | +| 13 | Premium | ++---------+------------+ ++ +
Output:
+ +++---------------+-------------+--------------+ +| week_of_month | membership | total_amount | ++---------------+-------------+--------------+ +| 1 | Premium | 1126 | +| 1 | VIP | 0 | +| 2 | Premium | 0 | +| 2 | VIP | 7473 | +| 3 | Premium | 0 | +| 3 | VIP | 0 | +| 4 | Premium | 5117 | +| 4 | VIP | 14933 | ++---------------+-------------+--------------+ ++ +
Explanation:
+ +Note: The output table is ordered by week_of_month and membership in ascending order.
+