class Solution {
public boolean hasGroupsSizeX(int[] deck) {
int N = deck.length;
int[] count = new int[10000];
for (int c: deck)
count[c]++;
List<Integer> values = new ArrayList();
for (int i = 0; i < 10000; ++i)
if (count[i] > 0)
values.add(count[i]);
search: for (int X = 2; X <= N; ++X)
if (N % X == 0) {
for (int v: values)
if (v % X != 0)
continue search;
return true;
}
return false;
}
}
leetcode 问题
最新推荐文章于 2022-04-08 21:32:44 发布