Use HashMap instead of pointers


#1

Map<Integer,Integer> map=new HashMap();
for(int i=a.size()-1;i>=0;i–){
if(map.containsKey(a.get(i)+b)){
return 1;
}
map.put(a.get(i),i);
}
return 0;


#2

Although this is simpler than using 2 pointers, you waste O(n) memory, and achieve the same runtime.
Also you could’ve used a set instead, since you don’t need the indexes.