Simple Ruby solution


  • 0
    N
    def contains_duplicate(nums)
        hash = {}
        nums.each do |num|
            if hash.has_key?(num)
                return true
            else
                hash[num] = true
            end
        end
        return false
    end

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.