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 704da9f commit 5ec8787Copy full SHA for 5ec8787
2932.Maximum-strong-pair-xor-i.java
@@ -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
27
28
29
+}
0 commit comments