Problem List
O(n) O(n)func distributeCandies(candyType []int) int {
n := len(candyType) / 2
m := make(map[int]bool)
for _, num := range candyType {
m[num] = true
if len(m) >= n {
return n
}
}
return min(len(m), n)
}
func min(a,b int) int {
if a < b {
return a
}
return b
}