https://leetcode-cn.com/problems/array-of-doubled-pairs/
class Solution {
public boolean canReorderDoubled(int[] arr) {
HashMap<Integer,Integer> map=new HashMap<>();
for(int a:arr){
map.put(a,map.getOrDefault(a,0)+1);
}
ArrayList<Integer> list=new ArrayList<>();
for(int v:map.keySet()){
list.add(v);
}
Collections.sort(list,(a,b)->(Math.abs(a)-Math.abs(b)));
for(int v:list){
if(map.getOrDefault(2*v,0)<map.get(v)){
return false;
}
map.put(2*v,map.getOrDefault(2*v,0)-map.get(v));
}
return true;
}
}