Skip to content

Commit 989ea19

Browse files
committed
deploy: 424dc09
1 parent ace1c26 commit 989ea19

File tree

12 files changed

+1053
-70
lines changed

12 files changed

+1053
-70
lines changed

en/lc/17/index.html

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

en/lc/3210/index.html

Lines changed: 90 additions & 8 deletions
Large diffs are not rendered by default.

en/lc/3211/index.html

Lines changed: 206 additions & 8 deletions
Large diffs are not rendered by default.

en/lc/3212/index.html

Lines changed: 215 additions & 8 deletions
Large diffs are not rendered by default.

en/lc/724/index.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22160,9 +22160,9 @@
2216022160
<ul class="md-nav__list">
2216122161

2216222162
<li class="md-nav__item">
22163-
<a href="#solution-1" class="md-nav__link">
22163+
<a href="#solution-1-prefix-sum" class="md-nav__link">
2216422164
<span class="md-ellipsis">
22165-
Solution 1
22165+
Solution 1: Prefix Sum
2216622166
</span>
2216722167
</a>
2216822168

@@ -77186,7 +77186,16 @@ <h2 id="description">Description</h2>
7718677186
<h2 id="solutions">Solutions</h2>
7718777187
<!-- solution:start -->
7718877188

77189-
<h3 id="solution-1">Solution 1</h3>
77189+
<h3 id="solution-1-prefix-sum">Solution 1: Prefix Sum</h3>
77190+
<p>We define a variable $left$ to represent the sum of elements to the left of index $i$ in the array $\textit{nums}$, and a variable $right$ to represent the sum of elements to the right of index $i$ in the array $\textit{nums}$. Initially, $left = 0$, $right = \sum_{i = 0}^{n - 1} nums[i]$.</p>
77191+
<p>We traverse the array $\textit{nums}$. For the current number $x$ being traversed, we update $right = right - x$. At this point, if $left = right$, it indicates that the current index $i$ is the middle position, and we can return it directly. Otherwise, we update $left = left + x$ and continue to traverse the next number.</p>
77192+
<p>If the middle position is not found by the end of the traversal, return $-1$.</p>
77193+
<p>The time complexity is $O(n)$, and the space complexity is $O(1)$. Here, $n$ is the length of the array $\textit{nums}$.</p>
77194+
<p>Similar Problems:</p>
77195+
<ul>
77196+
<li><a href="https://github.com/doocs/leetcode/blob/main/solution/1900-1999/1991.Find%20the%20Middle%20Index%20in%20Array/README_EN.md">1991. Find the Middle Index in Array</a></li>
77197+
<li><a href="https://github.com/doocs/leetcode/blob/main/solution/2500-2599/2574.Left%20and%20Right%20Sum%20Differences/README_EN.md">2574. Left and Right Sum Differences</a></li>
77198+
</ul>
7719077199
<div class="tabbed-set tabbed-alternate" data-tabs="1:7"><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" /><input id="__tabbed_1_7" 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><label for="__tabbed_1_7">JavaScript</label></div>
7719177200
<div class="tabbed-content">
7719277201
<div class="tabbed-block">

en/search/search_index.json

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

lc/17/index.html

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

lc/3210/index.html

Lines changed: 89 additions & 7 deletions
Large diffs are not rendered by default.

lc/3211/index.html

Lines changed: 206 additions & 8 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)