Find Unique Element in Array
You have been provided an integer array/list ARR
of size N
. Here, N
is equivalent to 2M + 1
where each test case has M
numbers appearing twice and one number appearing exactly once.
Your task is to identify and return this unique number that appears only once.
Example:
Input:
t = 2
N = 5
ARR = [1, 2, 3, 2, 1]
N = 7
ARR = [4, 5, 6, 7, 7, 6, 5]
Output:
3
4
Explanation:
In the first test case, 3
is the only number that is not repeated. In the second test case, 4
is the number which appears only once.
Constraints:
1 ≤ t ≤ 102
0 ≤ N ≤ 103
- Time Limit: 1 sec
Note:
The unique element is guaranteed to be present in the array/list according to the given condition.

AnswerBot
1y
The task is to find the unique number in an array where all other numbers occur twice.
The array size is given by N = 2M + 1, where M is the number of elements occurring twice.
Loop through the array an...read more
IRFAN BEG
12mo
that arr has been called the
IRFAN BEG
12mo
the ans is 2
Add answer anonymously...
Josh Technology Group Front end Developer interview questions & answers
A Front end Developer was asked Q. Implement a live coding round to build a small CRUD-based application.
A Front end Developer was asked Q. Non-Decreasing Array Problem Statement Given an integer array ARR of size N, det...read more
A Front end Developer was asked Q. Diameter of a Binary Tree Problem Statement Given a binary tree, return the leng...read more
Popular interview questions of Front end Developer
A Front end Developer was asked Q1. Implement a live coding round to build a small CRUD-based application.
A Front end Developer was asked Q2. Non-Decreasing Array Problem Statement Given an integer array ARR of size N, det...read more
A Front end Developer was asked Q3. Diameter of a Binary Tree Problem Statement Given a binary tree, return the leng...read more
>
Josh Technology Group Front end Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

