mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-24 06:18:57 +08:00
48 lines
1.9 KiB
HTML
48 lines
1.9 KiB
HTML
<p>You are given a string <code>s</code> consisting of lowercase English letters.</p>
|
||
|
||
<p>The <strong>score</strong> of a string is the sum of the positions of its characters in the alphabet, where <code>'a' = 1</code>, <code>'b' = 2</code>, ..., <code>'z' = 26</code>.</p>
|
||
|
||
<p>Determine whether there exists an index <code>i</code> such that the string can be split into two <strong>non-empty</strong> <strong><strong><span data-keyword="substring-nonempty">substrings</span></strong></strong> <code>s[0..i]</code> and <code>s[(i + 1)..(n - 1)]</code> that have <strong>equal</strong> scores.</p>
|
||
|
||
<p>Return <code>true</code> if such a split exists, otherwise return <code>false</code>.</p>
|
||
|
||
<p> </p>
|
||
<p><strong class="example">Example 1:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>Input:</strong> <span class="example-io">s = "adcb"</span></p>
|
||
|
||
<p><strong>Output:</strong> <span class="example-io">true</span></p>
|
||
|
||
<p><strong>Explanation:</strong></p>
|
||
|
||
<p>Split at index <code>i = 1</code>:</p>
|
||
|
||
<ul>
|
||
<li>Left substring = <code>s[0..1] = "ad"</code> with <code>score = 1 + 4 = 5</code></li>
|
||
<li>Right substring = <code>s[2..3] = "cb"</code> with <code>score = 3 + 2 = 5</code></li>
|
||
</ul>
|
||
|
||
<p>Both substrings have equal scores, so the output is <code>true</code>.</p>
|
||
</div>
|
||
|
||
<p><strong class="example">Example 2:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>Input:</strong> <span class="example-io">s = "bace"</span></p>
|
||
|
||
<p><strong>Output:</strong> <span class="example-io">false</span></p>
|
||
|
||
<p><strong>Explanation:</strong></p>
|
||
|
||
<p><strong></strong>No split produces equal scores, so the output is <code>false</code>.</p>
|
||
</div>
|
||
|
||
<p> </p>
|
||
<p><strong>Constraints:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>2 <= s.length <= 100</code></li>
|
||
<li><code>s</code> consists of lowercase English letters.</li>
|
||
</ul>
|