6 kyu

Find the unique number

1,896 of 2,172kayahr

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 Trained4542
Total Skips130
Total Code Submissions8184
Total Times Completed2172
JavaScript Completions1896
Haskell Completions178
Ruby Completions140
Total Stars88
% of votes with a positive feedback rating92% of 355
Total "Very Satisfied" Votes305
Total "Somewhat Satisfied" Votes45
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