Created
January 22, 2019 02:38
-
-
Save schaitanya/01515bde210787f951933ade6ab12649 to your computer and use it in GitHub Desktop.
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
package main | |
import "fmt" | |
func main() { | |
fmt.Println(containsDuplicate([]int{1, 2, 3, 4})) | |
} | |
func containsDuplicate(nums []int) bool { | |
ret := make(map[int]bool, len(nums)) | |
for j := 0; j < len(nums); j++ { | |
if ret[nums[j]] { | |
return true | |
} else { | |
ret[nums[j]] = true | |
} | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment