Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Dec 10, 2023
1 parent 41074e4 commit 4dbb50f
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"fmt"
)

func uniqueOccurrences(arr []int) bool {
cnt := map[int]int{}
for _, x := range arr {
cnt[x]++
}
vis := map[int]bool{}
for _, v := range cnt {
if vis[v] {
return false
}
vis[v] = true
}
return true
}

func main() {
arr := []int{1, 2, 2, 1, 1, 3}
fmt.Println(uniqueOccurrences(arr))
}

0 comments on commit 4dbb50f

Please sign in to comment.