时间复杂度 O(n),空间复杂度 O(n)
func distributeCandies(candyType []int) int {
set := map[int]struct{}{}
for _, t := range candyType {
set[t] = struct{}{}
}
ans := len(candyType) / 2
if len(set) < ans {
ans = len(set)
}
return ans
}
能分到最大糖果的种类数会是 所有糖果种类数 和 糖果数量一半 两者中最小的那个