Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6420
@blackshadows 6380
@mb1973 5704
@Quandray 5245
@akhayrutdinov 5111
@saiujwal13083 5046
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3523
@mantu_singh 3510
@sushant_a 3459
Complete Leaderboard
Exceptionally odd
Basic Accuracy: 70.15% Submissions: 4950 Points: 1

Given an array of N positive integers where all numbers occur even number of times except one number which occurs odd number of times. Find the exceptional number.

Example 1:

Input:
N = 7
Arr[] = {1, 2, 3, 2, 3, 1, 3}
Output: 3

Example 2:

Input:
N = 7
Arr[] = {5, 7, 2, 7, 5, 2, 5}
Output: 5

Your Task:
You don't need to read input or print anything. Your task is to complete the function getOddOccurrence() which takes arr[] and as input parameters and returns the exceptional number.


Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)


Constraints:
1 ≤ N ≤ 105
1 ≤ arr[i] ≤ 106

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Exceptionally odd

Output Window