luoheng
10/6/2019 - 2:55 PM

uniqueOccurrences

func uniqueOccurrences(arr []int) bool {
    count := [2001]int{}
    for _, a := range arr {
        count[a+1000]++
    }
    times := make(map[int]bool, 10)
    for _, c := range count {
        if c == 0 {
            continue
        }
        if _, ok := times[c]; ok {
            return false
        }
        times[c] = true
    }
    return true
}