#C9381. Detect Duplicates in an Array
Detect Duplicates in an Array
Detect Duplicates in an Array
You are given an array of integers. Your task is to determine whether there exist any duplicates in the array. In other words, you should output True
if there exists at least one pair of indices (i) and (j) (with (i \neq j)) such that (a_i = a_j), and False
otherwise.
Input Format:
- The first line contains a single integer \(n\), representing the number of elements in the array.
- The second line contains \(n\) space-separated integers representing the elements of the array.
Output Format:
- Output a single line: either
True
if the array contains duplicates, orFalse
if it does not.
Example:
Input: 5 1 2 3 4 5 Output: False
inputFormat
Input: The first line contains an integer (n) ( (1 \leq n \leq 10^5)) denoting the number of elements. The second line contains (n) space-separated integers.
outputFormat
Output: A single line with either True
or False
indicating whether the array contains duplicates.## sample
5
1 2 3 4 5
False