#C2462. Detecting Duplicates in an Integer Array
Detecting Duplicates in an Integer Array
Detecting Duplicates in an Integer Array
You are given an integer array. Your task is to determine whether the array contains any duplicates. In other words, check if there exists any element which appears at least twice in the array.
The input starts with an integer \(n\) indicating the number of elements in the array, followed by \(n\) space-separated integers. Your program should output True
if any duplicate exists and False
if all elements are unique.
Note: Use efficient methods to handle the duplicate check. For instance, you may use the idea of a set that only stores unique values.
inputFormat
The first line contains an integer \(n\) indicating the number of elements in the array. The second line contains \(n\) space-separated integers.
outputFormat
Print a single line with True
if there is at least one duplicate in the array, otherwise print False
.
4
1 2 3 1
True