Skip to content

Commit 8420923

Browse files
committed
deploy: 04070a3
1 parent d17b525 commit 8420923

File tree

9 files changed

+7452
-7364
lines changed

9 files changed

+7452
-7364
lines changed

en/lc/2237/index.html

Lines changed: 57 additions & 14 deletions
Large diffs are not rendered by default.

en/lc/2239/index.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54377,9 +54377,9 @@
5437754377
<ul class="md-nav__list">
5437854378

5437954379
<li class="md-nav__item">
54380-
<a href="#solution-1" class="md-nav__link">
54380+
<a href="#solution-1-one-pass" class="md-nav__link">
5438154381
<span class="md-ellipsis">
54382-
Solution 1
54382+
Solution 1: One Pass
5438354383
</span>
5438454384
</a>
5438554385

@@ -81785,7 +81785,10 @@ <h2 id="description">Description</h2>
8178581785
<h2 id="solutions">Solutions</h2>
8178681786
<!-- solution:start -->
8178781787

81788-
<h3 id="solution-1">Solution 1</h3>
81788+
<h3 id="solution-1-one-pass">Solution 1: One Pass</h3>
81789+
<p>We define a variable $d$ to record the current minimum distance, initially $d=\infty$. Then we traverse the array, for each element $x$, we calculate $y=|x|$. If $y \lt d$ or $y=d$ and $x \gt ans$, we update the answer $ans=x$ and $d=y$.</p>
81790+
<p>After the traversal, return the answer.</p>
81791+
<p>Time complexity is $O(n)$, where $n$ is the length of the array. Space complexity is $O(1)$.</p>
8178981792
<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>
8179081793
<div class="tabbed-content">
8179181794
<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)