Problem title
Difficulty
Avg time to solve

Ninja And Editor
Easy
20 mins
Encoded Letter
Moderate
25 mins
Tree Jumping
Hard
50 mins
Base Conversion
Easy
15 mins
Number of ones in the smallest repunit
Moderate
30 mins
Conversion
Easy
20 mins
Remove Comments
Moderate
15 mins
Last Substring In Lexicographical Order
Hard
45 mins
Minimum And Maximum
Easy
15 mins
Rectangles In N x N Board
Moderate
20 mins

Detect Odd

Difficulty: MEDIUM
Contributed By
Avg. time to solve
25 min
Success Rate
75%

Problem Statement

You are given an array of ‘N’ non-negative integers where all elements appear an even number of times except two, print the two odd occurring elements in increasing order. It may be assumed that the size of the array is at-least two and there will always be exactly two numbers which appear an odd number of times in the given array.

EXAMPLE:
Input: 'N' = 6, 'NUMS' = [1, 1, 2, 3, 4, 4]
Output: 2 3

Here in the given array we can see that 2 and 3 occur 1 time which is an odd number. Hence, the output will be 2 and 3.
Input Format :
The first line of the input contains an integer, 'T’, denoting the number of test cases.

The first line of each test case will contain a single integer ‘N’, denoting the size of the array.

The second line of each test case contains ‘N’ space-separated integers denoting elements of the array.
Output format :
For each test case, print the two numbers in increasing order separated by space which appear an odd number of times in the given array.
Note :
You don't need to print anything. It has already been taken care of. Just implement the given function.
Constraints :
1 <= 'T' <= 10
2 <= 'N' <= 10^4
1 <= 'NUMS[i]' <= 10^5

Time Limit: 1 sec
Sample Input 1 :
2
6
1 1 2 3 4 4
2
1 2
Sample Output 1 :
2 3
1 2
Explanation Of Sample Input 1 :
For the first test case,
'N' = 6 and 'NUMS' = [1, 1, 2, 3, 4, 4]
Here in the given array we can see that 2 and 3 occur 1 time which is an odd  number. Hence, the output will be 2 and 3.

For the second test case,
'N' = 2 and 'NUMS' = [1, 2]
Here in the given array we can see that 1 and 2 occur 1 time which is an odd  number. Hence, the output will be 1 and 2.
Sample Input 2 :
2
4
8 2 2 7
4
3 1 3 5
Sample Output 2 :
7 8   
1 5
Reset Code
Full screen
copy-code
Console