1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-02 22:13:28 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>Alice 和 Bob 玩一个游戏,两人轮流行动,<strong>Alice 先手</strong> 。</p>\n\n<p>给你一个 <strong>偶数长度</strong> 的字符串 <code>num</code> ,每一个字符为数字字符或者 <code>'?'</code> 。每一次操作中,如果 <code>num</code> 中至少有一个 <code>'?'</code> ,那么玩家可以执行以下操作:</p>\n\n<ol>\n\t<li>选择一个下标 <code>i</code> 满足 <code>num[i] == '?'</code> 。</li>\n\t<li>将 <code>num[i]</code> 用 <code>'0'</code> 到 <code>'9'</code> 之间的一个数字字符替代。</li>\n</ol>\n\n<p>当 <code>num</code> 中没有<span style=\"\"> </span><code>'?'</code> 时,游戏结束。</p>\n\n<p>Bob 获胜的条件是 <code>num</code> 中前一半数字的和 <strong>等于</strong> 后一半数字的和。Alice 获胜的条件是前一半的和与后一半的和 <strong>不相等</strong> 。</p>\n\n<ul>\n\t<li>比方说,游戏结束时 <code>num = \"243801\"</code> 那么 Bob 获胜,因为 <code>2+4+3 = 8+0+1</code> 。如果游戏结束时 <code>num = \"243803\"</code> ,那么 Alice 获胜,因为 <code>2+4+3 != 8+0+3</code> 。</li>\n</ul>\n\n<p>在 Alice 和 Bob 都采取 <strong>最优</strong> 策略的前提下,如果 Alice 获胜,请返回 <code>true</code> ,如果 Bob 获胜,请返回 <code>false</code> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<b>输入:</b>num = \"5023\"\n<b>输出:</b>false\n<b>解释:</b>num 中没有 '?' ,没法进行任何操作。\n前一半的和等于后一半的和5 + 0 = 2 + 3 。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<b>输入:</b>num = \"25??\"\n<b>输出:</b>true\n<strong>解释:</strong>Alice 可以将两个 '?' 中的一个替换为 '9' Bob 无论如何都无法使前一半的和等于后一半的和。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<b>输入:</b>num = \"?3295???\"\n<b>输出:</b>false\n<b>解释:</b>Bob 总是能赢。一种可能的结果是:\n- Alice 将第一个 '?' 用 '9' 替换。num = \"93295???\" 。\n- Bob 将后面一半中的一个 '?' 替换为 '9' 。num = \"932959??\" 。\n- Alice 将后面一半中的一个 '?' 替换为 '2' 。num = \"9329592?\" 。\n- Bob 将后面一半中最后一个 '?' 替换为 '7' 。num = \"93295927\" 。\nBob 获胜,因为 9 + 3 + 2 + 9 = 5 + 9 + 2 + 7 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>2 <= num.length <= 10<sup>5</sup></code></li>\n\t<li><code>num.length</code> 是 <strong>偶数</strong> 。</li>\n\t<li><code>num</code> 只包含数字字符和 <code>'?'</code> 。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 14,
"likes": 15,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"2.2K\", \"totalSubmission\": \"5.2K\", \"totalAcceptedRaw\": 2173, \"totalSubmissionRaw\": 5191, \"acRate\": \"41.9%\"}",
"stats": "{\"totalAccepted\": \"2.2K\", \"totalSubmission\": \"5.3K\", \"totalAcceptedRaw\": 2244, \"totalSubmissionRaw\": 5336, \"acRate\": \"42.1%\"}",
"hints": [
"Bob can always make the total sum of both sides equal in mod 9.",
"Why does the difference between the number of question marks on the left and right side matter?"