Skip to content

Commit 62282d0

Browse files
authored
Create 2932-maximum-strong-pair-xor-i.js
1 parent 934c049 commit 62282d0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

2932-maximum-strong-pair-xor-i.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number}
4+
*/
5+
var maximumStrongPairXor = function(nums) {
6+
const n = nums.length
7+
let res = -Infinity
8+
for(let i = 0; i < n; i++) {
9+
const x = nums[i]
10+
for(let j = i; j < n; j++) {
11+
const y = nums[j]
12+
if(Math.abs(x - y) <= Math.min(x, y) && (x ^ y) > res) {
13+
res = x ^ y
14+
}
15+
}
16+
}
17+
return res
18+
};

0 commit comments

Comments
 (0)