blob: 4abf63d278ea6c9b0279093b44184911cffd4d9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import java.util.Arrays;
public class Ch2 {
public static void main(String[] args) {
System.out.println(digit_count_value(new int[]{1, 2, 1, 0}));
System.out.println(digit_count_value(new int[]{0, 3, 0}));
}
private static boolean digit_count_value(int[] arr) {
int[] hash = new int[10];
Arrays.fill(hash, 0);
for (int i = 0; i < arr.length; ++i) hash[arr[i] % 10]++;
for (int i = 0; i < arr.length; ++i) if (hash[i] != arr[i]) return false;
return true;
}
}
|