Skip to content

Commit 5ec8787

Browse files
committed
feat(leetcode): add No.2932
1 parent 704da9f commit 5ec8787

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// https://leetcode.com/problems/maximum-strong-pair-xor-i/description/
2+
// algorithms
3+
// Easy (74.9%)
4+
// Total Accepted: 15.9K
5+
// Total Submissions: 21.2K
6+
7+
class Solution {
8+
9+
public int maximumStrongPairXor(int[] nums) {
10+
int res = 0;
11+
int length = nums.length;
12+
if (length == 1) {
13+
return res;
14+
}
15+
16+
Arrays.sort(nums);
17+
for (int i = 0; i < length; i++) {
18+
for (int j = i + 1; j < length; j++) {
19+
if (nums[j] - nums[i] > nums[i]) {
20+
break;
21+
}
22+
res = Math.max(res, nums[i] ^ nums[j]);
23+
}
24+
}
25+
26+
return res;
27+
}
28+
29+
}

0 commit comments

Comments
 (0)