From 4bec960edd51a22e865b5cb6610ad6ffa0a31578 Mon Sep 17 00:00:00 2001 From: yanglbme Date: Mon, 15 Apr 2024 09:41:25 +0800 Subject: [PATCH] feat: add sql solution to lc problem: No.3118 No.3118.Friday Purchase III --- .../README_EN.md | 2 +- .../2700-2799/2796.Repeat String/README_EN.md | 3 + .../README_EN.md | 18 +- .../README_EN.md | 32 ++-- .../README_EN.md | 2 +- .../3118.Friday Purchase III/README.md | 158 ++++++++++++++++++ .../3118.Friday Purchase III/README_EN.md | 156 +++++++++++++++++ .../3118.Friday Purchase III/Solution.sql | 28 ++++ solution/DATABASE_README.md | 1 + solution/DATABASE_README_EN.md | 1 + solution/README.md | 1 + solution/README_EN.md | 1 + 12 files changed, 383 insertions(+), 20 deletions(-) create mode 100644 solution/3100-3199/3118.Friday Purchase III/README.md create mode 100644 solution/3100-3199/3118.Friday Purchase III/README_EN.md create mode 100644 solution/3100-3199/3118.Friday Purchase III/Solution.sql 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 @@ ## Solutions diff --git a/solution/2700-2799/2796.Repeat String/README_EN.md b/solution/2700-2799/2796.Repeat String/README_EN.md index f805a8b5ed562..4a4df730d7f17 100644 --- a/solution/2700-2799/2796.Repeat String/README_EN.md +++ b/solution/2700-2799/2796.Repeat String/README_EN.md @@ -43,6 +43,9 @@
  • 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 @@ -

    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.

    @@ -28,15 +28,15 @@

    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: