Given an array of integers, where each integer is in the range [1, n], write a program to find a duplicate in the array.
Input:
Output:
Example 1
Input: 5 1 3 4 2 2
Output: 2
The duplicate in the array is 2.
Constraints
Hints
Given an array of integers, where each integer is in the range [1, n], write a program to find a duplicate in the array.
Input:
Output:
Example 1
Input: 5 1 3 4 2 2
Output: 2
The duplicate in the array is 2.
Constraints
Hints