Duplicate Integer in Array
Given an array ARR
of size N
, containing each number between 1 and N-1
at least once, identify the single integer that appears twice.
Input:
The first line contains an integer, 'T', representing the number of test cases.
The first line of each test case contains a single integer, 'N', indicating the array size.
The second line contains 'N' space-separated integers denoting the elements of the array 'ARR'.
Output:
For each test case, return the duplicate number in the array. Output should be a single integer per test case, each on a new line.
Example:
Input:
ARR = [1, 2, 3, 4, 4]
Output:
4
Explanation:
The duplicate integer present in the array is 4.
Constraints:
1 <= T <= 10
2 <= N <= 10^5
1 <= ARR[i] <= N - 1
- A duplicate number is guaranteed to be present in the array.
- Time limit: 1 sec.

AnswerBot
4mo
Identify the duplicate integer in an array containing numbers between 1 and N-1.
Iterate through the array and keep track of the frequency of each element using a hashmap.
Return the element with a freq...read more
Help your peers!
Add answer anonymously...
Ernst & Young Senior Software Engineer interview questions & answers
A Senior Software Engineer was asked Q. For SSRS reports, why are temporary tables used instead of regular tables?
A Senior Software Engineer was asked Q. How is memory managed in Python?
A Senior Software Engineer was asked 12mo agoQ. Technology used
Popular interview questions of Senior Software Engineer
A Senior Software Engineer was asked Q1. For SSRS reports, why are temporary tables used instead of regular tables?
A Senior Software Engineer was asked Q2. How is memory managed in Python?
A Senior Software Engineer was asked 12mo agoQ3. Technology used
>
Ernst & Young Senior Software Engineer 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

