#C11151. Permutation Check
Permutation Check
Permutation Check
You are given an array of n integers. Your task is to determine whether the given array is a permutation of the first n positive integers. In other words, check if the array contains every number from \(1\) to \(n\) exactly once.
A permutation must satisfy the condition that if \(n\) is the length of the array, then the set of numbers in the array is exactly \(\{1, 2, \dots, n\}\).
If the array is a permutation, print "YES"; otherwise, print "NO".
inputFormat
The input is given via standard input and consists of two lines:
- The first line contains a single integer \(n\) \( (1 \leq n \leq 10^5)\) representing the number of elements in the array.
- The second line contains \(n\) space-separated integers representing the elements of the array.
outputFormat
Output a single line to standard output containing "YES" if the array is a permutation of the integers from \(1\) to \(n\), otherwise output "NO".
## sample5
3 1 4 5 2
YES