1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/数组中两个数的最大异或值 [maximum-xor-of-two-numbers-in-an-array].html
2022-03-29 12:43:11 +08:00

54 lines
1.2 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 ≤ i ≤ j < n</code></p>
<p><strong>进阶:</strong>你可以在 <code>O(n)</code> 的时间解决这个问题吗?</p>
<p> </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> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= nums.length <= 2 * 10<sup>4</sup></code></li>
<li><code>0 <= nums[i] <= 2<sup>31</sup> - 1</code></li>
</ul>
</div>
</div>