Interview Question

Engineer Interview Hyderābād (India)

given an array with N elements (~ 2n+1), which contains

  positive integers. All the numbers are repeating (i.e. they exist in pairs) except one. Find the non-repeating number.
Answer

Interview Answer

1 Answer

1

an xor (exclusive OR) of all the numbers will return the number repeating only once.

Aditya on Aug 1, 2011

Add Answers or Comments

To comment on this question, Sign In with Facebook or Sign Up