Update appNew update is available. Click here to update.
sidenav-btnClose
Topic list
Detect Odd
MEDIUM
25 mins
Bit Manipulation
Topics (Covered in this problem)
Problem solved
Badge
Skill meter
Bit Manipulation
-
-
Other topics
Problem solved
Badge
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
Linked List
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
userLevel
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

Detect Odd

Contributed by
KAPEESH UPADHYAY
Medium
yellow-spark
0/80
Avg time to solve 25 mins
Success Rate 75 %
Share
0 upvotes

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.
Detailed explanation ( Input/output format, Notes, Constraints, Images )
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
Auto
copy-code
Console