programming-examples/ruby/Algorithms/find_single_number.rb

10 lines
198 B
Ruby
Raw Normal View History

2019-11-15 12:59:38 +01:00
# Given an array of integers, every element appears twice except for one.
# Find that single one.
# @param {Integer[]} nums
# @return {Integer}
def single_number(numbers)
numbers.reduce(:^)
end