mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-08 00:41:42 +08:00
移除零宽空格
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
"boundTopicId": 722724,
|
||||
"title": "Maximum XOR for Each Query",
|
||||
"titleSlug": "maximum-xor-for-each-query",
|
||||
"content": "<p>You are given a <strong>sorted</strong> array <code>nums</code> of <code>n</code> non-negative integers and an integer <code>maximumBit</code>. You want to perform the following query <code>n</code> <strong>times</strong>:</p>\n\n<ol>\n\t<li>Find a non-negative integer <code>k < 2<sup>maximumBit</sup></code> such that <code>nums[0] XOR nums[1] XOR ... XOR nums[nums.length-1] XOR k</code> is <strong>maximized</strong>. <code>k</code> is the answer to the <code>i<sup>th</sup></code> query.</li>\n\t<li>Remove the <strong>last </strong>element from the current array <code>nums</code>.</li>\n</ol>\n\n<p>Return <em>an array</em> <code>answer</code><em>, where </em><code>answer[i]</code><em> is the answer to the </em><code>i<sup>th</sup></code><em> query</em>.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [0,1,1,3], maximumBit = 2\n<strong>Output:</strong> [0,3,2,3]\n<strong>Explanation</strong>: The queries are answered as follows:\n1<sup>st</sup> query: nums = [0,1,1,3], k = 0 since 0 XOR 1 XOR 1 XOR 3 XOR 0 = 3.\n2<sup>nd</sup> query: nums = [0,1,1], k = 3 since 0 XOR 1 XOR 1 XOR 3 = 3.\n3<sup>rd</sup> query: nums = [0,1], k = 2 since 0 XOR 1 XOR 2 = 3.\n4<sup>th</sup> query: nums = [0], k = 3 since 0 XOR 3 = 3.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [2,3,4,7], maximumBit = 3\n<strong>Output:</strong> [5,2,6,5]\n<strong>Explanation</strong>: The queries are answered as follows:\n1<sup>st</sup> query: nums = [2,3,4,7], k = 5 since 2 XOR 3 XOR 4 XOR 7 XOR 5 = 7.\n2<sup>nd</sup> query: nums = [2,3,4], k = 2 since 2 XOR 3 XOR 4 XOR 2 = 7.\n3<sup>rd</sup> query: nums = [2,3], k = 6 since 2 XOR 3 XOR 6 = 7.\n4<sup>th</sup> query: nums = [2], k = 5 since 2 XOR 5 = 7.\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [0,1,2,2,5,7], maximumBit = 3\n<strong>Output:</strong> [4,3,6,4,6,7]\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>nums.length == n</code></li>\n\t<li><code>1 <= n <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= maximumBit <= 20</code></li>\n\t<li><code>0 <= nums[i] < 2<sup>maximumBit</sup></code></li>\n\t<li><code>nums</code> is sorted in <strong>ascending</strong> order.</li>\n</ul>\n",
|
||||
"content": "<p>You are given a <strong>sorted</strong> array <code>nums</code> of <code>n</code> non-negative integers and an integer <code>maximumBit</code>. You want to perform the following query <code>n</code> <strong>times</strong>:</p>\n\n<ol>\n\t<li>Find a non-negative integer <code>k < 2<sup>maximumBit</sup></code> such that <code>nums[0] XOR nums[1] XOR ... XOR nums[nums.length-1] XOR k</code> is <strong>maximized</strong>. <code>k</code> is the answer to the <code>i<sup>th</sup></code> query.</li>\n\t<li>Remove the <strong>last </strong>element from the current array <code>nums</code>.</li>\n</ol>\n\n<p>Return <em>an array</em> <code>answer</code><em>, where </em><code>answer[i]</code><em> is the answer to the </em><code>i<sup>th</sup></code><em> query</em>.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [0,1,1,3], maximumBit = 2\n<strong>Output:</strong> [0,3,2,3]\n<strong>Explanation</strong>: The queries are answered as follows:\n1<sup>st</sup> query: nums = [0,1,1,3], k = 0 since 0 XOR 1 XOR 1 XOR 3 XOR 0 = 3.\n2<sup>nd</sup> query: nums = [0,1,1], k = 3 since 0 XOR 1 XOR 1 XOR 3 = 3.\n3<sup>rd</sup> query: nums = [0,1], k = 2 since 0 XOR 1 XOR 2 = 3.\n4<sup>th</sup> query: nums = [0], k = 3 since 0 XOR 3 = 3.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [2,3,4,7], maximumBit = 3\n<strong>Output:</strong> [5,2,6,5]\n<strong>Explanation</strong>: The queries are answered as follows:\n1<sup>st</sup> query: nums = [2,3,4,7], k = 5 since 2 XOR 3 XOR 4 XOR 7 XOR 5 = 7.\n2<sup>nd</sup> query: nums = [2,3,4], k = 2 since 2 XOR 3 XOR 4 XOR 2 = 7.\n3<sup>rd</sup> query: nums = [2,3], k = 6 since 2 XOR 3 XOR 6 = 7.\n4<sup>th</sup> query: nums = [2], k = 5 since 2 XOR 5 = 7.\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [0,1,2,2,5,7], maximumBit = 3\n<strong>Output:</strong> [4,3,6,4,6,7]\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>nums.length == n</code></li>\n\t<li><code>1 <= n <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= maximumBit <= 20</code></li>\n\t<li><code>0 <= nums[i] < 2<sup>maximumBit</sup></code></li>\n\t<li><code>nums</code> is sorted in <strong>ascending</strong> order.</li>\n</ul>\n",
|
||||
"translatedTitle": "每个查询的最大异或值",
|
||||
"translatedContent": "<p>给你一个 <strong>有序</strong> 数组 <code>nums</code> ,它由 <code>n</code> 个非负整数组成,同时给你一个整数 <code>maximumBit</code> 。你需要执行以下查询 <code>n</code> 次:</p>\n\n<ol>\n\t<li>找到一个非负整数 <code>k < 2<sup>maximumBit</sup></code> ,使得 <code>nums[0] XOR nums[1] XOR ... XOR nums[nums.length-1] XOR k</code> 的结果 <strong>最大化</strong> 。<code>k</code> 是第 <code>i</code> 个查询的答案。</li>\n\t<li>从当前数组 <code>nums</code> 删除 <strong>最后</strong> 一个元素。</li>\n</ol>\n\n<p>请你返回一个数组 <code>answer</code> ,其中<em> </em><code>answer[i]</code>是第 <code>i</code> 个查询的结果。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [0,1,1,3], maximumBit = 2\n<b>输出:</b>[0,3,2,3]\n<b>解释:</b>查询的答案如下:\n第一个查询:nums = [0,1,1,3],k = 0,因为 0 XOR 1 XOR 1 XOR 3 XOR 0 = 3 。\n第二个查询:nums = [0,1,1],k = 3,因为 0 XOR 1 XOR 1 XOR 3 = 3 。\n第三个查询:nums = [0,1],k = 2,因为 0 XOR 1 XOR 2 = 3 。\n第四个查询:nums = [0],k = 3,因为 0 XOR 3 = 3 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [2,3,4,7], maximumBit = 3\n<b>输出:</b>[5,2,6,5]\n<b>解释:</b>查询的答案如下:\n第一个查询:nums = [2,3,4,7],k = 5,因为 2 XOR 3 XOR 4 XOR 7 XOR 5 = 7。\n第二个查询:nums = [2,3,4],k = 2,因为 2 XOR 3 XOR 4 XOR 2 = 7 。\n第三个查询:nums = [2,3],k = 6,因为 2 XOR 3 XOR 6 = 7 。\n第四个查询:nums = [2],k = 5,因为 2 XOR 5 = 7 。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [0,1,2,2,5,7], maximumBit = 3\n<b>输出:</b>[4,3,6,4,6,7]\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>nums.length == n</code></li>\n\t<li><code>1 <= n <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= maximumBit <= 20</code></li>\n\t<li><code>0 <= nums[i] < 2<sup>maximumBit</sup></code></li>\n\t<li><code>nums</code> 中的数字已经按 <strong>升序</strong> 排好序。</li>\n</ul>\n",
|
||||
"translatedContent": "<p>给你一个 <strong>有序</strong> 数组 <code>nums</code> ,它由 <code>n</code> 个非负整数组成,同时给你一个整数 <code>maximumBit</code> 。你需要执行以下查询 <code>n</code> 次:</p>\n\n<ol>\n\t<li>找到一个非负整数 <code>k < 2<sup>maximumBit</sup></code> ,使得 <code>nums[0] XOR nums[1] XOR ... XOR nums[nums.length-1] XOR k</code> 的结果 <strong>最大化</strong> 。<code>k</code> 是第 <code>i</code> 个查询的答案。</li>\n\t<li>从当前数组 <code>nums</code> 删除 <strong>最后</strong> 一个元素。</li>\n</ol>\n\n<p>请你返回一个数组 <code>answer</code> ,其中<em> </em><code>answer[i]</code>是第 <code>i</code> 个查询的结果。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [0,1,1,3], maximumBit = 2\n<b>输出:</b>[0,3,2,3]\n<b>解释:</b>查询的答案如下:\n第一个查询:nums = [0,1,1,3],k = 0,因为 0 XOR 1 XOR 1 XOR 3 XOR 0 = 3 。\n第二个查询:nums = [0,1,1],k = 3,因为 0 XOR 1 XOR 1 XOR 3 = 3 。\n第三个查询:nums = [0,1],k = 2,因为 0 XOR 1 XOR 2 = 3 。\n第四个查询:nums = [0],k = 3,因为 0 XOR 3 = 3 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [2,3,4,7], maximumBit = 3\n<b>输出:</b>[5,2,6,5]\n<b>解释:</b>查询的答案如下:\n第一个查询:nums = [2,3,4,7],k = 5,因为 2 XOR 3 XOR 4 XOR 7 XOR 5 = 7。\n第二个查询:nums = [2,3,4],k = 2,因为 2 XOR 3 XOR 4 XOR 2 = 7 。\n第三个查询:nums = [2,3],k = 6,因为 2 XOR 3 XOR 6 = 7 。\n第四个查询:nums = [2],k = 5,因为 2 XOR 5 = 7 。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [0,1,2,2,5,7], maximumBit = 3\n<b>输出:</b>[4,3,6,4,6,7]\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>nums.length == n</code></li>\n\t<li><code>1 <= n <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= maximumBit <= 20</code></li>\n\t<li><code>0 <= nums[i] < 2<sup>maximumBit</sup></code></li>\n\t<li><code>nums</code> 中的数字已经按 <strong>升序</strong> 排好序。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 34,
|
||||
|
Reference in New Issue
Block a user