575. 分糖果
代码:
class Solution {
public int distributeCandies(int[] candies) {
Set<Integer> candie = new HashSet<>();
int kinds = 0;
for (int i = 0; i < candies.length; i++) candie.add(candies[i]);
if (candie.size() < (candies.length / 2)) kinds = candie.size();
else kinds = candies.length / 2;
return kinds;
}
}