6 kyu

Find the unique number

1,840 of 2,114kayahr

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 Trained4447
Total Skips126
Total Code Submissions8067
Total Times Completed2114
JavaScript Completions1840
Haskell Completions178
Ruby Completions138
Total Stars87
% of votes with a positive feedback rating92% of 346
Total "Very Satisfied" Votes297
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