1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/数组中两个数的最大异或值 [ms70jA].html

60 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>5</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>