![]() |
Sum it up solution How about xor ing each number with the next. When the ones bit doesn't change - you have the extra number. Works in both cases.
Tom Hopkins
You could also loop the numbers and always substract the current number (n) from the previous (m), and if n-m would equal zero then n is the repeater. Works with both sets, and also if there were any number of repeating numbers.
MP
What if you are not guaranteed that the numbers are in order? My guess is that is what the problem intended, even though the example set is ordered.
Will Smith
|