Distribute Candies
LeetCode題目: 575. Distribute Candies
My solution:
/**
* @param {number[]} candyType
* @return {number}
*/
let distributeCandies = candyType => {
const types = new Set(candyType);
const halfCandy = candyType.length / 2;
return types.size >= halfCandy ? halfCandy : types.size;
};
