fork download
  1. class Solution {
  2. public long subarrayXor(int arr[], int k) {
  3. int n =arr.length;
  4.  
  5. HashMap<Integer,Integer>f = new HashMap<>();
  6.  
  7. int[] prefixxor = new int[n];
  8.  
  9. prefixxor[0]=arr[0];
  10. for(int i=1;i<n;i++){
  11. prefixxor[i]=prefixxor[i-1]^arr[i];
  12. }
  13.  
  14. f.put(0,1);
  15. long count=0;
  16.  
  17. for(int i=0;i<n;i++){
  18. if(f.containsKey(prefixxor[i]^k)){
  19. count+=f.getOrDefault(prefixxor[i]^k,0);
  20. }
  21. f.put(prefixxor[i],f.getOrDefault(prefixxor[i],0)+1);
  22. }
  23.  
  24. return count;
  25. }
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:5: error: cannot find symbol
        HashMap<Integer,Integer>f = new HashMap<>();
        ^
  symbol:   class HashMap
  location: class Solution
Main.java:5: error: cannot find symbol
        HashMap<Integer,Integer>f = new HashMap<>();
                                        ^
  symbol:   class HashMap
  location: class Solution
2 errors
stdout
Standard output is empty