Non Repeating Numbers
Easy Accuracy: 49.85% Submissions: 25636 Points: 2

Given an array A containing 2*N+2 positive numbers, out of which 2*N numbers exist in pairs whereas the other two number occur exactly once and are distinct. Find the other two numbers.

Example 1:

N = 2
arr[] = {1, 2, 3, 2, 1, 4}
3 4 
3 and 4 occur exactly once.

Example 2:

N = 1
arr[] = {2, 1, 3, 2}
1 3
1 3 occur exactly once.

Your Task:
You do not need to read or print anything. Your task is to complete the function singleNumber() which takes the array as input parameter and returns a list of two numbers which occur exactly once in the array. The list must be in ascending order.

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

1 <= length of array <= 10

1 <= Elements in array <= 5 * 106

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


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


All Submissions

My Submissions:

Login to access your submissions.

Non Repeating Numbers

Output Window