题目
用一个set存储,然后遍历数组,看当前值的2倍和1/2是否存在,要保证是整除。
class Solution {
public boolean checkIfExist(int[] arr) {
HashSet<Integer> set = new HashSet<>();
for(int a:arr){
if(set.contains(a*2) || ((a&1)==0)&&set.contains(a/2)) return true;
set.add(a);
}
return false;
}
}