# Challenge name: Single Number # # Given a non-empty array of integers nums, every element appears twice # except for one. Find that single one. # # Follow up: Could you implement a solution with a linear runtime # complexity and without using extra memory? # # @param {Integer[]} nums # @return {Integer} def single_number(nums) end nums = [2, 2, 1] puts(single_number(nums)) # Output: 1 nums = [4, 1, 2, 1, 2] puts(single_number(nums)) # Output: 4 nums = [1] puts(single_number(nums)) # Output: 1