image_2021-12-06_23-38-19.png
26.5 KB
#N575. Distribute Candies
problem link
#solution
problem link
#solution
class Solution {
public int distributeCandies(int[] candyType) {
Set<Integer> set = new HashSet<>();
for(int candy:candyType)
set.add(candy);
return Math.min(set.size(), candyType.length/2);
}
}