Created
March 14, 2021 05:49
-
-
Save minhphong306/674b3e5e5270a864bd199c12918187f3 to your computer and use it in GitHub Desktop.
sol2.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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