Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int findMaximumXOR(vector<int>& nums) {
- int mask = 0, ans = 0;
- for(int i = 31; i >= 0; --i){
- mask |= (1 << i);
- set<int> s;
- for(int j = 0; j < nums.size(); ++j){
- s.insert(nums[j] & mask);
- }
- int cand = ans |(1 << i);
- for(auto x : s){
- if(s.find(x ^ cand) != s.end()){
- ans = cand;
- break;
- }
- }
- }
- return ans;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement