Update appNew update is available. Click here to update.
sidenav-btnClose
Topic list
Single Number
EASY
10 mins
18 upvotes
Arrays
Bit Manipulation
Topics (Covered in this problem)
Problem solved
Badge
Skill meter
Arrays
-
-
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
-
-
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.

Single Number

Contributed by
Naresh
Easy
yellow-spark
0/40
Avg time to solve 10 mins
Success Rate 90 %
Share
18 upvotes

Problem Statement

You are given an array A of length N, where N is always an odd integer. There are (N-1)/2 elements in the array that occur twice and one element which occurs once. Your task is to find the only element that occurs once in the array.

Note: There are (N-1)/2+1 elements that are unique in the array.

Detailed explanation ( Input/output format, Notes, Constraints, Images )
Sample Input 1:
2
7
7 3 5 4 5 3 4
9
5 6 9 6 1 9 1 5 3
Sample Output 1:
7
3
Explanation For Sample Input 1:
In the first test case the integers 3, 4, 5 occur twice and only the integer 7 occurs once.

In the second test case the integers 1, 5, 6, 9 occur twice and only the integer 3 occurs once.
Sample Input 2:
3
1
5
3
6 9 6
5
6 9 3 6 3
Sample Output 2:
5
9
9
Reset Code
Full screen
Auto
copy-code
Console