package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/maximum-xor-for-each-query/
 */
public class Problem1829 {
    public int[] getMaximumXor(int[] nums, int maximumBit) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1829 prob = new Problem1829();
        System.out.println(Arrays.toString(prob.getMaximumXor(new int[]{0,1,1,3}, 2))); // [0,3,2,3]
        System.out.println(Arrays.toString(prob.getMaximumXor(new int[]{2,3,4,7}, 3))); // [5,2,6,5]
        System.out.println(Arrays.toString(prob.getMaximumXor(new int[]{0,1,2,2,5,7}, 3))); // [4,3,6,4,6,7]
    }
}

@@ -16,34 +16,8 @@
 e;%0A%0A
-import java.util.Arrays;%0A%0A
 /**%0A
@@ -181,445 +181,339 @@
     
-// TODO%0A        return null;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1829 prob = new Problem1829();%0A        System.out.println(Arrays.toString(prob.getMaximumXor(new int%5B%5D%7B0,1,1,3%7D, 2))); // %5B0,3,2,3%5D%0A        System.out.println(Arrays.toString(prob.getMaximumXor(new int%5B%5D%7B2,3,4,7%7D, 3))); // %5B5,2,6,5%5D%0A        System.out.println(Arrays.toString(prob.getMaximumXor(new int%5B%5D%7B0,1,2,2,5,7%7D, 3))); // %5B4,3,6,4,6,7%5D
+int%5B%5D answer = new int%5Bnums.length%5D;%0A        int prefixXor = 0;%0A        for (int i = 0; i %3C nums.length; i++) %7B%0A            prefixXor %5E= nums%5Bi%5D;%0A            int k = ((int) Math.pow(2, maximumBit)) - 1;%0A            // a %5E b = c --%3E a %5E c = b%0A            answer%5Bnums.length - 1 - i%5D = prefixXor %5E k;%0A        %7D%0A        return answer;
 %0A   

Solve problem 1829