Skip to content

Instantly share code, notes, and snippets.

@abdulrahmanAlotaibi
Created December 15, 2022 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdulrahmanAlotaibi/133f556887f1bbd00e1714ae48c4fe04 to your computer and use it in GitHub Desktop.
Save abdulrahmanAlotaibi/133f556887f1bbd00e1714ae48c4fe04 to your computer and use it in GitHub Desktop.
Array # 7 : Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
func containsDuplicate(nums []int) bool {
for i:= 0 ; i < len(nums) ; i++ {
n := nums[i]
for j:= 0; j < len(nums) ; j++ {
if j != i && nums[j] == n {
return true
}
}
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment