3 Line Ruby Solution


  • 0
    R
    def find_duplicates(nums)
        nums.each_with_object([]) do |num, array|
          nums[num.abs - 1] < 0 ? array << num.abs : nums[num.abs - 1] *= -1
        end
    end
    

Log in to reply
 

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