Skip to content

Instantly share code, notes, and snippets.

@minhphong306
Created March 14, 2021 05:49
Show Gist options
  • Save minhphong306/674b3e5e5270a864bd199c12918187f3 to your computer and use it in GitHub Desktop.
Save minhphong306/674b3e5e5270a864bd199c12918187f3 to your computer and use it in GitHub Desktop.
sol2.go
func sol2(arr []int) int {
mapCheck := make(map[int]int)
for i := 0; i < len(arr); i++ {
mapCheck[arr[i]]++
}
for key, value := range mapCheck {
if value > 1 {
return key
}
}
return -1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment