mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-07 00:11:41 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>一个数组的<strong> 异或总和</strong> 定义为数组中所有元素按位 <code>XOR</code> 的结果;如果数组为 <strong>空</strong> ,则异或总和为 <code>0</code> 。</p>\n\n<ul>\n\t<li>例如,数组 <code>[2,5,6]</code> 的 <strong>异或总和</strong> 为 <code>2 XOR 5 XOR 6 = 1</code> 。</li>\n</ul>\n\n<p>给你一个数组 <code>nums</code> ,请你求出 <code>nums</code> 中每个 <strong>子集</strong> 的 <strong>异或总和</strong> ,计算并返回这些值相加之 <strong>和</strong> 。</p>\n\n<p><strong>注意:</strong>在本题中,元素 <strong>相同</strong> 的不同子集应 <strong>多次</strong> 计数。</p>\n\n<p>数组 <code>a</code> 是数组 <code>b</code> 的一个 <strong>子集</strong> 的前提条件是:从 <code>b</code> 删除几个(也可能不删除)元素能够得到 <code>a</code> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre><strong>输入:</strong>nums = [1,3]\n<strong>输出:</strong>6\n<strong>解释:</strong>[1,3] 共有 4 个子集:\n- 空子集的异或总和是 0 。\n- [1] 的异或总和为 1 。\n- [3] 的异或总和为 3 。\n- [1,3] 的异或总和为 1 XOR 3 = 2 。\n0 + 1 + 3 + 2 = 6\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre><strong>输入:</strong>nums = [5,1,6]\n<strong>输出:</strong>28\n<strong>解释:</strong>[5,1,6] 共有 8 个子集:\n- 空子集的异或总和是 0 。\n- [5] 的异或总和为 5 。\n- [1] 的异或总和为 1 。\n- [6] 的异或总和为 6 。\n- [5,1] 的异或总和为 5 XOR 1 = 4 。\n- [5,6] 的异或总和为 5 XOR 6 = 3 。\n- [1,6] 的异或总和为 1 XOR 6 = 7 。\n- [5,1,6] 的异或总和为 5 XOR 1 XOR 6 = 2 。\n0 + 5 + 1 + 6 + 4 + 3 + 7 + 2 = 28\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre><strong>输入:</strong>nums = [3,4,5,6,7,8]\n<strong>输出:</strong>480\n<strong>解释:</strong>每个子集的全部异或总和值之和为 480 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= nums.length <= 12</code></li>\n\t<li><code>1 <= nums[i] <= 20</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 78,
|
||||
"likes": 83,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -161,7 +161,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"16.1K\", \"totalSubmission\": \"18.5K\", \"totalAcceptedRaw\": 16125, \"totalSubmissionRaw\": 18476, \"acRate\": \"87.3%\"}",
|
||||
"stats": "{\"totalAccepted\": \"16.8K\", \"totalSubmission\": \"19.4K\", \"totalAcceptedRaw\": 16788, \"totalSubmissionRaw\": 19376, \"acRate\": \"86.6%\"}",
|
||||
"hints": [
|
||||
"Is there a way to iterate through all the subsets of the array?",
|
||||
"Can we use recursion to efficiently iterate through all the subsets?"
|
||||
|
Reference in New Issue
Block a user