1 2 3 4 5 6 7 8 9 10 11 12
| class Solution { public: vector<int> getMaximumXor(vector<int>& nums, int maximumBit) { int n = nums.size(), mask = 0, target = (1 << maximumBit) - 1; vector<int> ans(n); for (int num : nums) { mask ^= num; ans[--n] = (mask ^ target); } return ans; } };
|