Leetcode in Java && Oracle
421 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-12-06_23-38-19.png
26.5 KB
#N575. Distribute Candies
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);
}
}