JAVA_Distribute Candies_LeetCode 575


JAVA_Distribute Candies_LeetCode 575

JAVA_Distribute Candies_LeetCode 575 풀이 class Solution { public int distributeCandies(int[] candyType) { Set<Integer> cset = new HashSet<>(); for (int c : candyType) cset.add(c); return Math.min(cset.size(), candyType.length / 2); } } * 출처 Distribute Candies - LeetCode Distribute Candies - Alice has n candies, where the ith candy is of type candyType[i]. Alice noticed that she started to gain weight, so she visited a doctor. The doctor advised Alice to only eat n / 2 of the candies she has (n is...


#DistributeCandies_LeetCode575 #JAVA #JAVA_DistributeCandies #JAVA_DistributeCandies_LeetCode575 #JAVA_LeetCode575

원문링크 : JAVA_Distribute Candies_LeetCode 575