What's your answer to this interview question?
One array, excluding one number, all other numbers in the array appear in pair. How to find the position of the number which is not in pair. For example, an array of numbers ……102,102,2,2,44,44,99,23,23,11,11 ……. The number 99 is not in pair. One more question, if the paired numbers are not adjacent to each other, i.e. an array of [102,32,99,32,45,102,45,67,67,100,100], how do you find the position of 99?
1 ANSWER
Use exclusive or to find the number which is not in pair. Then find the position of the number in the array. The code for finding the number which is not in pair is:
| |
POST ANSWER
Sorry! You need to login first to post answer.
OR
Factory mode is open |
By sonic0002 |
RECENT
- ► What does your personal desk look like?
- ► Happy Chinese New Year for those who celebrate it
- ► How much time do you code every day?
- ► What lies would programmers like to tell?
- ► Is GoLang being used in more and more startups?
- ► How do you feel about 996?
- ► What are your reasons not writing blogs?
- ► Why do you or do not write tech blogs?
- ► What weekend projects have you created?
- ► What's your opinion about Alibaba mooncake incident?