#K88462. Permutation Transformation
Permutation Transformation
Permutation Transformation
Given an array of integers and a positive integer \(n\), determine whether the array can be rearranged to form a permutation of the first \(n\) natural numbers \(\{1, 2, \ldots, n\}\).
A valid permutation contains each integer from 1 to \(n\) exactly once. Your task is to verify that the given array meets these conditions.
inputFormat
The input is given via \(stdin\) and starts with an integer \(T\) representing the number of test cases. Each test case consists of two lines:
- The first line contains a single integer \(n\), the number of elements in the array.
- The second line contains \(n\) space-separated integers representing the array.
outputFormat
For each test case, output a single line to \(stdout\) with "YES" if the array can be rearranged into a permutation of \(\{1, 2, \ldots, n\}\), or "NO" otherwise.
## sample4
5
1 2 3 4 5
5
1 2 2 4 5
5
1 3 5 2 4
1
2
YES
NO
YES
NO
</p>