Skip to content

Commit 9d91745

Browse files
committed
deploy: eae0c1f
1 parent 405419e commit 9d91745

File tree

7 files changed

+237
-315
lines changed

7 files changed

+237
-315
lines changed

en/lc/1926/index.html

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

en/lc/1927/index.html

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47857,9 +47857,9 @@
4785747857
<ul class="md-nav__list">
4785847858

4785947859
<li class="md-nav__item">
47860-
<a href="#solution-1" class="md-nav__link">
47860+
<a href="#solution-1-case-analysis" class="md-nav__link">
4786147861
<span class="md-ellipsis">
47862-
Solution 1
47862+
Solution 1: Case Analysis
4786347863
</span>
4786447864
</a>
4786547865

@@ -82198,7 +82198,18 @@ <h2 id="description">Description</h2>
8219882198
<h2 id="solutions">Solutions</h2>
8219982199
<!-- solution:start -->
8220082200

82201-
<h3 id="solution-1">Solution 1</h3>
82201+
<h3 id="solution-1-case-analysis">Solution 1: Case Analysis</h3>
82202+
<p>If the number of <code>'?'</code> is odd, Alice will definitely win because she can choose to replace the last <code>'?'</code> with any digit, making the sum of the first half different from the sum of the second half.</p>
82203+
<p>If the number of <code>'?'</code> is even, Alice will try to make the sums of the two halves different by placing $9$ in the half with the larger current sum and $0$ in the half with the smaller current sum. Bob, on the other hand, will try to make the sums equal by placing a digit in the other half that matches the digit Alice placed.</p>
82204+
<p>As a result, all remaining even-numbered <code>'?'</code> will be concentrated in one half. Suppose the current difference between the sums of the two halves is $d$.</p>
82205+
<p>Let's consider the case where there are two remaining <code>'?'</code> and the difference is $x$:</p>
82206+
<ul>
82207+
<li>If $x \lt 9$, Alice will definitely win because she can replace one of the <code>'?'</code> with $9$, making the sums of the two halves different.</li>
82208+
<li>If $x \gt 9$, Alice will definitely win because she can replace one of the <code>'?'</code> with $0$, making the sums of the two halves different.</li>
82209+
<li>If $x = 9$, Bob will definitely win. Suppose Alice replaces a digit with $a$, then Bob can replace the other <code>'?'</code> with $9 - a$, making the sums of the two halves equal.</li>
82210+
</ul>
82211+
<p>Therefore, if the difference between the sums of the two halves is $d = \frac{9 \times \textit{cnt}}{2}$, where $\textit{cnt}$ is the number of remaining <code>'?'</code>, Bob will definitely win; otherwise, Alice will definitely win.</p>
82212+
<p>The time complexity is $O(n)$, where $n$ is the length of the string. The space complexity is $O(1)$.</p>
8220282213
<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>
8220382214
<div class="tabbed-content">
8220482215
<div class="tabbed-block">

en/lc/1941/index.html

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

en/search/search_index.json

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

lc/1926/index.html

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

0 commit comments

Comments
 (0)