Skip to content

Commit 26985a5

Browse files
committed
deploy: 94e5644
1 parent 4857d0f commit 26985a5

File tree

12 files changed

+941
-33
lines changed

12 files changed

+941
-33
lines changed

en/lc/3369/index.html

Lines changed: 439 additions & 5 deletions
Large diffs are not rendered by default.

en/lc/3370/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78046,9 +78046,9 @@
7804678046
<ul class="md-nav__list">
7804778047

7804878048
<li class="md-nav__item">
78049-
<a href="#solution-1" class="md-nav__link">
78049+
<a href="#solution-1-bit-manipulation" class="md-nav__link">
7805078050
<span class="md-ellipsis">
78051-
Solution 1
78051+
Solution 1: Bit Manipulation
7805278052
</span>
7805378053
</a>
7805478054

@@ -80866,7 +80866,9 @@ <h2 id="description">Description</h2>
8086680866
<h2 id="solutions">Solutions</h2>
8086780867
<!-- solution:start -->
8086880868

80869-
<h3 id="solution-1">Solution 1</h3>
80869+
<h3 id="solution-1-bit-manipulation">Solution 1: Bit Manipulation</h3>
80870+
<p>We start with $x = 1$ and continuously left shift $x$ until $x - 1 \geq n$. At this point, $x - 1$ is the answer we are looking for.</p>
80871+
<p>The time complexity is $O(\log n)$, and the space complexity is $O(1)$.</p>
8087080872
<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>
8087180873
<div class="tabbed-content">
8087280874
<div class="tabbed-block">

en/lc/3371/index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78067,9 +78067,9 @@
7806778067
<ul class="md-nav__list">
7806878068

7806978069
<li class="md-nav__item">
78070-
<a href="#solution-1" class="md-nav__link">
78070+
<a href="#solution-1-hash-table-enumeration" class="md-nav__link">
7807178071
<span class="md-ellipsis">
78072-
Solution 1
78072+
Solution 1: Hash Table + Enumeration
7807378073
</span>
7807478074
</a>
7807578075

@@ -80882,7 +80882,11 @@ <h2 id="description">Description</h2>
8088280882
<h2 id="solutions">Solutions</h2>
8088380883
<!-- solution:start -->
8088480884

80885-
<h3 id="solution-1">Solution 1</h3>
80885+
<h3 id="solution-1-hash-table-enumeration">Solution 1: Hash Table + Enumeration</h3>
80886+
<p>We use a hash table $\textit{cnt}$ to record the frequency of each element in the array $\textit{nums}$.</p>
80887+
<p>Next, we enumerate each element $x$ in the array $\textit{nums}$ as a possible outlier. For each $x$, we calculate the sum $t$ of all elements in the array $\textit{nums}$ except $x$. If $t$ is not even, or half of $t$ is not in $\textit{cnt}$, then $x$ does not meet the condition, and we skip this $x$. Otherwise, if $x$ is not equal to half of $t$, or $x$ appears more than once in $\textit{cnt}$, then $x$ is a possible outlier, and we update the answer.</p>
80888+
<p>After enumerating all elements, we return the answer.</p>
80889+
<p>The time complexity is $O(n)$, and the space complexity is $O(n)$. Here, $n$ is the length of the array $\textit{nums}$.</p>
8088680890
<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>
8088780891
<div class="tabbed-content">
8088880892
<div class="tabbed-block">

en/lc/3372/index.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78088,9 +78088,9 @@
7808878088
<ul class="md-nav__list">
7808978089

7809078090
<li class="md-nav__item">
78091-
<a href="#solution-1" class="md-nav__link">
78091+
<a href="#solution-1-enumeration-dfs" class="md-nav__link">
7809278092
<span class="md-ellipsis">
78093-
Solution 1
78093+
Solution 1: Enumeration + DFS
7809478094
</span>
7809578095
</a>
7809678096

@@ -80879,7 +80879,14 @@ <h2 id="description">Description</h2>
8087980879
<h2 id="solutions">Solutions</h2>
8088080880
<!-- solution:start -->
8088180881

80882-
<h3 id="solution-1">Solution 1</h3>
80882+
<h3 id="solution-1-enumeration-dfs">Solution 1: Enumeration + DFS</h3>
80883+
<p>According to the problem description, to maximize the number of target nodes for node $i$, we must connect node $i$ to one of the nodes $j$ in the second tree. Therefore, the number of target nodes for node $i$ can be divided into two parts:</p>
80884+
<ul>
80885+
<li>In the first tree, the number of nodes reachable from node $i$ within a depth of $k$.</li>
80886+
<li>In the second tree, the maximum number of nodes reachable from any node $j$ within a depth of $k - 1$.</li>
80887+
</ul>
80888+
<p>Thus, we can first calculate the number of nodes reachable within a depth of $k - 1$ for each node in the second tree. Then, we enumerate each node $i$ in the first tree, calculate the sum of the two parts mentioned above, and take the maximum value.</p>
80889+
<p>The time complexity is $O(n^2 + m^2)$, and the space complexity is $O(n + m)$. Here, $n$ and $m$ are the number of nodes in the two trees, respectively.</p>
8088380890
<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">C#</label></div>
8088480891
<div class="tabbed-content">
8088580892
<div class="tabbed-block">

en/lc/3373/index.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78109,9 +78109,9 @@
7810978109
<ul class="md-nav__list">
7811078110

7811178111
<li class="md-nav__item">
78112-
<a href="#solution-1" class="md-nav__link">
78112+
<a href="#solution-1-dfs" class="md-nav__link">
7811378113
<span class="md-ellipsis">
78114-
Solution 1
78114+
Solution 1: DFS
7811578115
</span>
7811678116
</a>
7811778117

@@ -80878,7 +80878,14 @@ <h2 id="description">Description</h2>
8087880878
<h2 id="solutions">Solutions</h2>
8087980879
<!-- solution:start -->
8088080880

80881-
<h3 id="solution-1">Solution 1</h3>
80881+
<h3 id="solution-1-dfs">Solution 1: DFS</h3>
80882+
<p>The number of target nodes for node $i$ can be divided into two parts:</p>
80883+
<ul>
80884+
<li>The number of nodes in the first tree with the same depth parity as node $i$.</li>
80885+
<li>The maximum number of nodes in the second tree with the same depth parity.</li>
80886+
</ul>
80887+
<p>First, we use Depth-First Search (DFS) to calculate the number of nodes in the second tree with the same depth parity, denoted as $\textit{cnt2}$. Then, we calculate the number of nodes in the first tree with the same depth parity as node $i$, denoted as $\textit{cnt1}$. Therefore, the number of target nodes for node $i$ is $\max(\textit{cnt2}) + \textit{cnt1}$.</p>
80888+
<p>The time complexity is $O(n + m)$, and the space complexity is $O(n + m)$. Here, $n$ and $m$ are the number of nodes in the first and second trees, respectively.</p>
8088280889
<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">C#</label></div>
8088380890
<div class="tabbed-content">
8088480891
<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)