-
-
Save spreered/5df1ef1e029ab40ee831f777d43e4c57 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
# @param {Integer[]} nums | |
# @return {Boolean} | |
def contains_duplicate(nums) | |
na = nums.sort | |
na.each_index do |i| | |
if i<na.length | |
return true if na[i]== na[i+1] | |
end | |
end | |
return false | |
end |
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
def contains_duplicate(nums) | |
store = {} | |
nums.each do |num| | |
return true if store[num] | |
store[num] = true | |
end | |
return false | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment