public class Solution { public int FindMaximumXOR(int[] nums) { int max = 0, mask = 0; for (int i = 31; i >= 0; i--) { mask = mask | (1 << i); HashSet set = new HashSet (); foreach (int num in nums) { set.Add(num & mask); } int tmp = max | (1 << i); foreach (int prefix in set) { if (set.Contains(tmp ^ prefix)) { max = tmp; break; } } } return max; }}