Skip to content

Commit cb1bc26

Browse files
committed
deploy: f0e6867
1 parent 303992a commit cb1bc26

File tree

12 files changed

+7252
-7244
lines changed

12 files changed

+7252
-7244
lines changed

en/lc/2251/index.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54515,18 +54515,18 @@
5451554515
<ul class="md-nav__list">
5451654516

5451754517
<li class="md-nav__item">
54518-
<a href="#solution-1" class="md-nav__link">
54518+
<a href="#solution-1-sorting-binary-search" class="md-nav__link">
5451954519
<span class="md-ellipsis">
54520-
Solution 1
54520+
Solution 1: Sorting + Binary Search
5452154521
</span>
5452254522
</a>
5452354523

5452454524
</li>
5452554525

5452654526
<li class="md-nav__item">
54527-
<a href="#solution-2" class="md-nav__link">
54527+
<a href="#solution-2-difference-array-sorting-offline-query" class="md-nav__link">
5452854528
<span class="md-ellipsis">
54529-
Solution 2
54529+
Solution 2: Difference Array + Sorting + Offline Query
5453054530
</span>
5453154531
</a>
5453254532

@@ -80515,7 +80515,9 @@ <h2 id="description">Description</h2>
8051580515
<h2 id="solutions">Solutions</h2>
8051680516
<!-- solution:start -->
8051780517

80518-
<h3 id="solution-1">Solution 1</h3>
80518+
<h3 id="solution-1-sorting-binary-search">Solution 1: Sorting + Binary Search</h3>
80519+
<p>We sort the flowers by their start and end times. Then, for each person, we can use binary search to find the number of flowers in bloom when they arrive. This means finding the number of flowers that have started blooming by the time each person arrives, minus the number of flowers that have wilted by that time, to get the answer.</p>
80520+
<p>The time complexity is $O((m + n) \times \log n)$, and the space complexity is $O(n)$. Here, $n$ and $m$ are the lengths of the arrays $\textit{flowers}$ and $\textit{people}$, respectively.</p>
8051980521
<div class="tabbed-set tabbed-alternate" data-tabs="1:6"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><input id="__tabbed_1_3" name="__tabbed_1" type="radio" /><input id="__tabbed_1_4" name="__tabbed_1" type="radio" /><input id="__tabbed_1_5" name="__tabbed_1" type="radio" /><input id="__tabbed_1_6" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">Python3</label><label for="__tabbed_1_2">Java</label><label for="__tabbed_1_3">C++</label><label for="__tabbed_1_4">Go</label><label for="__tabbed_1_5">TypeScript</label><label for="__tabbed_1_6">Rust</label></div>
8052080522
<div class="tabbed-content">
8052180523
<div class="tabbed-block">
@@ -80840,7 +80842,9 @@ <h3 id="solution-1">Solution 1</h3>
8084080842

8084180843
<!-- solution:start -->
8084280844

80843-
<h3 id="solution-2">Solution 2</h3>
80845+
<h3 id="solution-2-difference-array-sorting-offline-query">Solution 2: Difference Array + Sorting + Offline Query</h3>
80846+
<p>We can use a difference array to maintain the number of flowers at each time point. Next, we sort $people$ by their arrival times in ascending order. When each person arrives, we perform a prefix sum operation on the difference array to get the answer.</p>
80847+
<p>The time complexity is $O(m \times \log m + n \times \log n)$, and the space complexity is $O(n + m)$. Here, $n$ and $m$ are the lengths of the arrays $\textit{flowers}$ and $\textit{people}$, respectively.</p>
8084480848
<div class="tabbed-set tabbed-alternate" data-tabs="2:5"><input checked="checked" id="__tabbed_2_1" name="__tabbed_2" type="radio" /><input id="__tabbed_2_2" name="__tabbed_2" type="radio" /><input id="__tabbed_2_3" name="__tabbed_2" type="radio" /><input id="__tabbed_2_4" name="__tabbed_2" type="radio" /><input id="__tabbed_2_5" name="__tabbed_2" type="radio" /><div class="tabbed-labels"><label for="__tabbed_2_1">Python3</label><label for="__tabbed_2_2">Java</label><label for="__tabbed_2_3">C++</label><label for="__tabbed_2_4">Go</label><label for="__tabbed_2_5">TypeScript</label></div>
8084580849
<div class="tabbed-content">
8084680850
<div class="tabbed-block">

en/lc/2259/index.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54683,18 +54683,18 @@
5468354683
<ul class="md-nav__list">
5468454684

5468554685
<li class="md-nav__item">
54686-
<a href="#solution-1" class="md-nav__link">
54686+
<a href="#solution-1-brute-force-enumeration" class="md-nav__link">
5468754687
<span class="md-ellipsis">
54688-
Solution 1
54688+
Solution 1: Brute Force Enumeration
5468954689
</span>
5469054690
</a>
5469154691

5469254692
</li>
5469354693

5469454694
<li class="md-nav__item">
54695-
<a href="#solution-2" class="md-nav__link">
54695+
<a href="#solution-2-greedy" class="md-nav__link">
5469654696
<span class="md-ellipsis">
54697-
Solution 2
54697+
Solution 2: Greedy
5469854698
</span>
5469954699
</a>
5470054700

@@ -80504,7 +80504,9 @@ <h2 id="description">Description</h2>
8050480504
<h2 id="solutions">Solutions</h2>
8050580505
<!-- solution:start -->
8050680506

80507-
<h3 id="solution-1">Solution 1</h3>
80507+
<h3 id="solution-1-brute-force-enumeration">Solution 1: Brute Force Enumeration</h3>
80508+
<p>We can enumerate all positions $\textit{i}$ in the string $\textit{number}$. If $\textit{number}[i] = \textit{digit}$, we take the prefix $\textit{number}[0:i]$ and the suffix $\textit{number}[i+1:]$ of $\textit{number}$ and concatenate them. This gives the result after removing $\textit{number}[i]$. We then take the maximum of all possible results.</p>
80509+
<p>The time complexity is $O(n^2)$, and the space complexity is $O(n)$. Here, $n$ is the length of the string $\textit{number}$.</p>
8050880510
<div class="tabbed-set tabbed-alternate" data-tabs="1:6"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><input id="__tabbed_1_3" name="__tabbed_1" type="radio" /><input id="__tabbed_1_4" name="__tabbed_1" type="radio" /><input id="__tabbed_1_5" name="__tabbed_1" type="radio" /><input id="__tabbed_1_6" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">Python3</label><label for="__tabbed_1_2">Java</label><label for="__tabbed_1_3">C++</label><label for="__tabbed_1_4">Go</label><label for="__tabbed_1_5">TypeScript</label><label for="__tabbed_1_6">PHP</label></div>
8050980511
<div class="tabbed-content">
8051080512
<div class="tabbed-block">
@@ -80685,7 +80687,9 @@ <h3 id="solution-1">Solution 1</h3>
8068580687

8068680688
<!-- solution:start -->
8068780689

80688-
<h3 id="solution-2">Solution 2</h3>
80690+
<h3 id="solution-2-greedy">Solution 2: Greedy</h3>
80691+
<p>We can enumerate all positions $\textit{i}$ in the string $\textit{number}$. If $\textit{number}[i] = \textit{digit}$, we record the last occurrence position of $\textit{digit}$ as $\textit{last}$. If $\textit{i} + 1 &lt; \textit{n}$ and $\textit{number}[i] &lt; \textit{number}[i + 1]$, then we can directly return $\textit{number}[0:i] + \textit{number}[i+1:]$ as the result after removing $\textit{number}[i]$. This is because if $\textit{number}[i] &lt; \textit{number}[i + 1]$, removing $\textit{number}[i]$ will result in a larger number.</p>
80692+
<p>After the traversal, we return $\textit{number}[0:\textit{last}] + \textit{number}[\textit{last}+1:]$.</p>
8068980693
<div class="tabbed-set tabbed-alternate" data-tabs="2:4"><input checked="checked" id="__tabbed_2_1" name="__tabbed_2" type="radio" /><input id="__tabbed_2_2" name="__tabbed_2" type="radio" /><input id="__tabbed_2_3" name="__tabbed_2" type="radio" /><input id="__tabbed_2_4" name="__tabbed_2" type="radio" /><div class="tabbed-labels"><label for="__tabbed_2_1">Python3</label><label for="__tabbed_2_2">Java</label><label for="__tabbed_2_3">C++</label><label for="__tabbed_2_4">Go</label></div>
8069080694
<div class="tabbed-content">
8069180695
<div class="tabbed-block">

en/lc/3243/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80516,10 +80516,10 @@ <h2 id="solutions">Solutions</h2>
8051680516
<!-- solution:start -->
8051780517

8051880518
<h3 id="solution-1-bfs">Solution 1: BFS</h3>
80519-
<p>First, we establish a directed graph $\textit{g}$, where $\textit{g}[i]$ represents the list of cities that can be reached from city $i$. Initially, each city $i$ has a one-way road leading to city $i + 1$.</p>
80520-
<p>Then, for each query $[u, v]$, we add $u$ to the departure city list of $v$, and then use BFS to find the shortest path length from city $0$ to city $n - 1$, adding the result to the answer array.</p>
80519+
<p>We first build a directed graph $\textit{g}$, where $\textit{g}[i]$ represents the list of cities that can be reached from city $i$. Initially, each city $i$ has a one-way road to city $i + 1$.</p>
80520+
<p>Then, for each query $[u, v]$, we add $v$ to the list of reachable cities from $u$, and then use BFS to find the shortest path length from city $0$ to city $n - 1$, adding the result to the answer array.</p>
8052180521
<p>Finally, we return the answer array.</p>
80522-
<p>Time complexity is $O(q \times (n + q))$, and space complexity is $O(n + q)$. Here, $n$ and $q$ are the number of cities and the number of queries, respectively.</p>
80522+
<p>The time complexity is $O(q \times (n + q))$, and the space complexity is $O(n + q)$. Here, $n$ and $q$ are the number of cities and the number of queries, respectively.</p>
8052380523
<div class="tabbed-set tabbed-alternate" data-tabs="1:5"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><input id="__tabbed_1_3" name="__tabbed_1" type="radio" /><input id="__tabbed_1_4" name="__tabbed_1" type="radio" /><input id="__tabbed_1_5" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">Python3</label><label for="__tabbed_1_2">Java</label><label for="__tabbed_1_3">C++</label><label for="__tabbed_1_4">Go</label><label for="__tabbed_1_5">TypeScript</label></div>
8052480524
<div class="tabbed-content">
8052580525
<div class="tabbed-block">

en/search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)