classSolution { // 利用性质: a ^ b = c ,则 a ^ c = b,且 b ^ c = a publicintfindMaximumXOR(int[] nums) { intres=0, mask = 0; for (inti=30; i >= 0; i--) { mask = mask | (1 << i); Set<Integer> set = newHashSet<>(); for (int num : nums) { set.add(num & mask); } inttemp= res | (1 << i); for (Integer prefix : set) { if (set.contains(prefix ^ temp)) { res = temp; break; } } } return res; } }