public class Solution { public int solve(int[] A, int B) { HashMap<Integer,Integer> hm=new HashMap<>(); int cnt=0; int sum=0; hm.put(0,1); for(int i=0;i<A.length;i++){ sum^=A[i]; if(hm.containsKey(sum^B)){ cnt+=hm.get(sum^B); }if(hm.containsKey(sum)){ hm.put(sum,hm.get(sum)+1); } else{ hm.put(sum,1); } } return cnt; } }