1.Holes in number
1,2,3,5,7 = 0 holes
0,4,6,9 = 1 holes
8 = 2 holes
input n;
publicintcountHoles(int n){if(n <0)return0;int[] arr ={1,0,0,0,1,0,1,0,2,1};int res =0;while(n >0){int temp = n %10;
res += arr[temp];
n /=10;}return res;}
public List<Long>distanceMetric(List<Integer> arr){
Long[] res =newLong[arr.size()];for(int i =0; i < arr.size(); i++){
res[i]=newLong(0);}//写的时候 放了一个错误把 i 和 j 的位置写反了,后面时间没了T T,幸好截图了才发现 原来 位置写反了。for(int i =0; i < arr.size(); i++){for(int j =0; j < arr.size(); j++){if(arr.get(i)== arr.get(j)&& i != j){int v = Math.abs(i - j);
res[i]+=newLong(v);}}}return Arrays.asList(res);}