`{"id":"9ba508cf-ca8e-498a-b5bb-c174c49efe5c","name":"Maximum Xor Of Two Numbers In An Array","description":"1. Given an integer array nums.\r\n2. return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":"1. 1 &lt;= nums.length &lt;= 2 * 10^5\r\n2. 0 &lt;= nums[i] &lt;= 2^31 - 1","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\n\nint findMaximumXor(vector<int> &nums)\n{\n return 0;\n}\nint main()\n{\n int n;\n cin>>n;\n vector<int> v(n);\n for(int i=0;i<n;i++)\n {\n int k;\n cin>>k;\n v.push_back(k);\n }\n int result = findMaximumXor(v);\n cout<<result;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n public static int findMaximumXOR(int[] nums) {\r\n // write your code here\r\n\r\n\r\n return 0;\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n BufferedReader read = new BufferedReader(new InputStreamReader(System.in));\r\n\r\n int n = Integer.parseInt(read.readLine().trim());\r\n int arr[] = new int[n];\r\n for (int i = 0; i < n; i++)arr[i] = Integer.parseInt(read.readLine().trim());\r\n\r\n int result = findMaximumXOR(arr);\r\n System.out.println(result);\r\n\r\n }\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"6\r\n3 \r\n10 \r\n5 \r\n25 \r\n2 \r\n8","sampleOutput":"28","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"4b4725b5-4896-4b68-aae2-03ea1e2ecbb2","name":"Trie For Intermediate","slug":"trie-for-intermediate-9996","type":0},{"id":"e9644e45-17a2-40e3-baf3-b6638046ecff","name":"Maximum Xor Of Two Numbers In An Array MCQ","slug":"maximum-xor-of-two-numbers-in-an-array-mcq","type":0},{"id":"7c1cea18-9cdb-4cc4-93d2-6add920e9d41","name":"Maximum Xor Of Two Numbers In An Array","slug":"maximum-xor-of-two-numbers-in-an-array","type":1}],"next":null,"prev":null}}`

# Maximum Xor Of Two Numbers In An Array

1. Given an integer array nums. 2. return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.

`{"id":"9ba508cf-ca8e-498a-b5bb-c174c49efe5c","name":"Maximum Xor Of Two Numbers In An Array","description":"1. Given an integer array nums.\r\n2. return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":"1. 1 &lt;= nums.length &lt;= 2 * 10^5\r\n2. 0 &lt;= nums[i] &lt;= 2^31 - 1","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\n\nint findMaximumXor(vector<int> &nums)\n{\n return 0;\n}\nint main()\n{\n int n;\n cin>>n;\n vector<int> v(n);\n for(int i=0;i<n;i++)\n {\n int k;\n cin>>k;\n v.push_back(k);\n }\n int result = findMaximumXor(v);\n cout<<result;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n public static int findMaximumXOR(int[] nums) {\r\n // write your code here\r\n\r\n\r\n return 0;\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n BufferedReader read = new BufferedReader(new InputStreamReader(System.in));\r\n\r\n int n = Integer.parseInt(read.readLine().trim());\r\n int arr[] = new int[n];\r\n for (int i = 0; i < n; i++)arr[i] = Integer.parseInt(read.readLine().trim());\r\n\r\n int result = findMaximumXOR(arr);\r\n System.out.println(result);\r\n\r\n }\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"6\r\n3 \r\n10 \r\n5 \r\n25 \r\n2 \r\n8","sampleOutput":"28","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"4b4725b5-4896-4b68-aae2-03ea1e2ecbb2","name":"Trie For Intermediate","slug":"trie-for-intermediate-9996","type":0},{"id":"e9644e45-17a2-40e3-baf3-b6638046ecff","name":"Maximum Xor Of Two Numbers In An Array MCQ","slug":"maximum-xor-of-two-numbers-in-an-array-mcq","type":0},{"id":"7c1cea18-9cdb-4cc4-93d2-6add920e9d41","name":"Maximum Xor Of Two Numbers In An Array","slug":"maximum-xor-of-two-numbers-in-an-array","type":1}],"next":null,"prev":null}}`

Editor

# Maximum Xor Of Two Numbers In An Array

medium

1. Given an integer array nums. 2. return the maximum result of nums[i] XOR nums[j], where 0

## Constraints

1. 1 <= nums.length <= 2 * 10^5 2. 0 <= nums[i] <= 2^31 - 1

## Format

### Input

Input is managed for you

### Output

Output is managed for you

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}6 3 10 5 25 2 8```

### Sample Output

`.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}28`

Discussions

Show Discussion

Related Resources