 New update is available. Click here to update.

# Duplicate In Array

Contributed by
Prateek_18cb
Last Updated: 23 Feb, 2023
Easy 0/40
Avg time to solve 15 mins
Success Rate 85 % Share 424 upvotes

## Problem Statement

#### For example:

``````Consider ARR = [1, 2, 3, 4, 4], the duplicate integer value present in the array is 4. Hence, the answer is 4 in this case.
``````
##### Note :
``````A duplicate number is always present in the given array.
``````
Detailed explanation ( Input/output format, Notes, Images ) ##### Constraints:
``````1 <=  T  <= 10
2 <=  N <= 10 ^ 5
1 <=  ARR[i]  <= N - 1

Where 'T' denotes the number of test cases, 'N' denotes the number of elements in the array, and 'ARR[i]' denotes the 'i-th' element of the array 'ARR'.

Time limit: 1 sec
``````
##### Sample Input 1:
``````2
5
4 2 1 3 1
7
6 3 1 5 4 3 2
``````
##### Sample Output 1:
``````1
3
``````
##### Explanation of sample input 1:
``````For the first test case,
The duplicate integer value present in the array is 1. Hence, the answer is 1 in this case.

For the second test case,
The duplicate integer value present in the array is 3. Hence, the answer is 3 in this case.
``````
##### Sample Input 2:
``````2
6
5 1 2 3 4 2
9
8 7 2 5 4 7 1 3 6
``````
##### Sample Output 2:
``````2
7
``````  Auto Console