We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7f4a91c commit 882cb7cCopy full SHA for 882cb7c
421-maximum-xor-of-two-numbers-in-an-array.js
@@ -1,3 +1,26 @@
1
+/**
2
+ * @param {number[]} nums
3
+ * @return {number}
4
+ */
5
+const findMaximumXOR = function(nums) {
6
+ let res = 0, mask = 0
7
+ for(let i = 31; i >= 0; i--) {
8
+ mask = mask | (1 << i)
9
+ const set = new Set()
10
+ for(let e of nums) set.add(e & mask)
11
+ const tmp = res | (1 << i)
12
+ for(let e of set) {
13
+ if(set.has(e ^ tmp)) {
14
+ res = tmp
15
+ break
16
+ }
17
18
19
+ return res
20
+};
21
+
22
+// another
23
24
/*
25
* @lc app=leetcode id=421 lang=javascript
26
*
0 commit comments