From 4dbb50f05ddbcc96566e5e24cd1c28aef8b91fd6 Mon Sep 17 00:00:00 2001 From: ductnn Date: Sun, 10 Dec 2023 18:29:07 +0700 Subject: [PATCH] add sol --- .../uniqueNumberOfOccurrences.go | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 leetcode/leetcode75/1207.UniqueNumberOfOccurrences/uniqueNumberOfOccurrences.go diff --git a/leetcode/leetcode75/1207.UniqueNumberOfOccurrences/uniqueNumberOfOccurrences.go b/leetcode/leetcode75/1207.UniqueNumberOfOccurrences/uniqueNumberOfOccurrences.go new file mode 100644 index 0000000..c7fb294 --- /dev/null +++ b/leetcode/leetcode75/1207.UniqueNumberOfOccurrences/uniqueNumberOfOccurrences.go @@ -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)) +}