X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Two numbers with odd occurrences
Easy Accuracy: 44.75% Submissions: 2693 Points: 2

Given an unsorted array, arr[] of size N and that contains even number of occurrences for all numbers except two numbers. Find the two numbers in decreasing order which has odd occurrences.

Example 1:

Input:
N = 8
Arr = {4, 2, 4, 5, 2, 3, 3, 1}
Output: {5, 1} 
Explaination: 5 and 1 have odd occurrences.


Example 2:

Input:
N = 6
Arr = {1 7 5 5 4 4}
Output: {7, 1}
Explaination: 7 and 1 have odd occurrences.


Your Task:
You don't need to read input or print anything. Your task is to complete the function twoOddNum() which takes the array Arr[] and its size as input parameters and returns the two numbers in decreasing order which have odd occurrences.


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


Constraints:
1 ≤ N ≤ 105
1 ≤ Arri ≤ 108

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.

Two numbers with odd occurrences

Output Window