1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 19:18:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/算法题(国内版)/problem (Chinese)/最大的异或 [ms70jA].html

60 lines
1.5 KiB
HTML
Raw Normal View History

2022-03-27 20:38:29 +08:00
<p>给定一个整数数组 <code>nums</code> ,返回<em> </em><code>nums[i] XOR nums[j]</code> 的最大运算结果,其中 <code>0 &le; i &le; j &lt; n</code></p>
<p>&nbsp;</p>
<div class="original__bRMd">
<div>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [3,10,5,25,2,8]
<strong>输出:</strong>28
<strong>解释:</strong>最大运算结果是 5 XOR 25 = 28.</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [0]
<strong>输出:</strong>0
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>nums = [2,4]
<strong>输出:</strong>6
</pre>
<p><strong>示例 4</strong></p>
<pre>
<strong>输入:</strong>nums = [8,10,2]
<strong>输出:</strong>10
</pre>
<p><strong>示例 5</strong></p>
<pre>
<strong>输入:</strong>nums = [14,70,53,83,49,91,36,80,92,51,66,70]
<strong>输出:</strong>127
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 2 * 10<sup>4</sup></code></li>
<li><code>0 &lt;= nums[i] &lt;= 2<sup>31</sup> - 1</code></li>
</ul>
</div>
</div>
<p>&nbsp;</p>
<p><strong>进阶:</strong>你可以在 <code>O(n)</code> 的时间解决这个问题吗?</p>
<p>&nbsp;</p>
<p><meta charset="UTF-8" />注意:本题与主站 421&nbsp;题相同:&nbsp;<a href="https://leetcode-cn.com/problems/maximum-xor-of-two-numbers-in-an-array/">https://leetcode-cn.com/problems/maximum-xor-of-two-numbers-in-an-array/</a></p>