1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-22 21:46:46 +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><strong>未知</strong> 整数数组 <code>arr</code> 由 <code>n</code> 个非负整数组成。</p>\n\n<p>经编码后变为长度为 <code>n - 1</code> 的另一个整数数组 <code>encoded</code> ,其中 <code>encoded[i] = arr[i] XOR arr[i + 1]</code> 。例如,<code>arr = [1,0,2,1]</code> 经编码后得到 <code>encoded = [1,2,3]</code> 。</p>\n\n<p>给你编码后的数组 <code>encoded</code> 和原数组 <code>arr</code> 的第一个元素 <code>first</code><code>arr[0]</code>)。</p>\n\n<p>请解码返回原数组 <code>arr</code> 。可以证明答案存在并且是唯一的。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>encoded = [1,2,3], first = 1\n<strong>输出:</strong>[1,0,2,1]\n<strong>解释:</strong>若 arr = [1,0,2,1] ,那么 first = 1 且 encoded = [1 XOR 0, 0 XOR 2, 2 XOR 1] = [1,2,3]\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>encoded = [6,2,7,3], first = 4\n<strong>输出:</strong>[4,2,0,7,4]\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>2 <= n <= 10<sup>4</sup></code></li>\n\t<li><code>encoded.length == n - 1</code></li>\n\t<li><code>0 <= encoded[i] <= 10<sup>5</sup></code></li>\n\t<li><code>0 <= first <= 10<sup>5</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 87,
"likes": 90,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -143,7 +143,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"48.9K\", \"totalSubmission\": \"56.3K\", \"totalAcceptedRaw\": 48911, \"totalSubmissionRaw\": 56333, \"acRate\": \"86.8%\"}",
"stats": "{\"totalAccepted\": \"49.5K\", \"totalSubmission\": \"57.1K\", \"totalAcceptedRaw\": 49533, \"totalSubmissionRaw\": 57099, \"acRate\": \"86.7%\"}",
"hints": [
"Since that encoded[i] = arr[i] XOR arr[i+1], then arr[i+1] = encoded[i] XOR arr[i].",
"Iterate on i from beginning to end, and set arr[i+1] = encoded[i] XOR arr[i]."