Obvious way in Ruby with hash.


  • 0
    K

    Nothing to brag about, just the first attempt

    # @return {Integer[]}
    def find_disappeared_numbers(nums)
        h=Hash[ *nums.collect { |v| [ v, true] }.flatten ]
        arr = []
        nums.size.times do |i| 
            arr << i+1 unless h[i+1]
        end
            arr
    end
    

Log in to reply
 

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