421. Maximum XOR of Two Numbers in an Array Medium
1/**
2 * [421] Maximum XOR of Two Numbers in an Array
3 *
4 * Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.
5 *
6 * Example 1:
7 *
8 * Input: nums = [3,10,5,25,2,8]
9 * Output: 28
10 * Explanation: The maximum result is 5 XOR 25 = 28.
11 *
12 * Example 2:
13 *
14 * Input: nums = [14,70,53,83,49,91,36,80,92,51,66,70]
15 * Output: 127
16 *
17 *
18 * Constraints:
19 *
20 * 1 <= nums.length <= 2 * 10^5
21 * 0 <= nums[i] <= 2^31 - 1
22 *
23 */
24pub struct Solution {}
25
26// problem: https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/
27// discuss: https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/discuss/?currentPage=1&orderBy=most_votes&query=
28
29// submission codes start here
30
31impl Solution {
32 pub fn find_maximum_xor(nums: Vec<i32>) -> i32 {
33 0
34 }
35}
36
37// submission codes end
38
39#[cfg(test)]
40mod tests {
41 use super::*;
42
43 #[test]
44 fn test_421() {
45 }
46}
47
Back
© 2025 bowen.ge All Rights Reserved.