6 kyu

Find the unique number

1,863 of 2,138kayahr

Description:

Write a function called findUnique which returns the only unique number from an array.

All numbers in the unsorted array are present twice, except the one you have to find. The numbers are always valid integer values between 1 and 2147483647, so no need for type and error checking. The array contains at least one number and may contain millions of numbers. So make sure your solution is optimized for speed.

Example

Input:

[ 1, 8, 4, 4, 6, 1, 8 ]

Expected output:

6
Arrays
Performance
Fundamentals

More By Author:

Check out these other kata created by kayahr

Stats:

CreatedSep 15, 2015
PublishedSep 15, 2015
Warriors Trained4491
Total Skips127
Total Code Submissions8116
Total Times Completed2138
JavaScript Completions1863
Haskell Completions178
Ruby Completions139
Total Stars88
% of votes with a positive feedback rating92% of 347
Total "Very Satisfied" Votes298
Total "Somewhat Satisfied" Votes44
Total "Not Satisfied" Votes5
Total Rank Assessments34
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • kayahr Avatar
  • bkaes Avatar
  • brunolm Avatar
  • JohanWiltink Avatar
  • adrian.eyre Avatar
  • Firefly2002 Avatar
  • Voile Avatar
  • Just4FunCoder Avatar
  • farhanaditya Avatar
Ad