'Coding has over 700 languages', '67% of programming jobs aren’t in the technology industry', 'Coding is behind almost everything that is powered by electricity'
Topics

One Odd Occurring

Easy
0/40
Average time to solve is 13m
profile
Contributed by
15 upvotes
Asked in companies
InfosysCapegemini Consulting India Private LimitedNagaaro

Problem statement

Given an array ‘ARR’ of ‘N’ integers, where all the elements occur an even number of times and only one number occurs an odd number of times.


Find and return the number which occurs an odd number of times.


For example:
'N' = 5, 'ARR' = [1, 2, 3, 2, 3]
Output: 1

Except for number 1, all numbers occur an even number of times.
Detailed explanation ( Input/output format, Notes, Images )
Sample Input 1 :
9
4 5 6 5 6 9 9 4 4
Sample Output 1 :
4
Explanation Of Sample Input 1 :
5, 6, and 9 occur an even number of times, and only 4 occur odd number of times.
Sample Input 2 :
5
1 1 1 1 1
Sample Output 2 :
1
Constraints :
1 <= 'N' <= 10^5

1 <= 'ARR[i]' <= 10^5

Time Limit: 1 sec
Full screen
Console