Created
December 15, 2022 23:27
-
-
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.
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 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