Loading...
Engaged Employer
How to find the unique integer in an array, where all the other numbers appear twice.
Anonymous
XOR all the elements into a variable and that variable will have the unique integer.
XOR is the right answer because all the other numbers occur only twice. So for {3,3,1} the answer is 1.
XOR will not work ... consider that u have array of 4 elements {3,3,3,1}. XORing them all gives u 2 which is incorrect.
Check out your Company Bowl for anonymous work chats.
Get actionable career advice tailored to you by joining more bowls.
Stay ahead in opportunities and insider tips by following your dream companies.
Get personalized job recommendations and updates by starting your searches.