Array Permutation
Time Limit: 1.0 s
Memory Limit: 256.0 MB
Description
Do you know what is permutation? If the answer is no, don't worry. Today, we learn about it.
For example, N = 5 ;
Permutation of N is { 1, 2, 3, 4, 5} means 1 to N (inclusive) numbers exactly once appear in the array.
You are given an Array A[] with N lengths, check whether Array A[] is a permutation of N or not.
Input
First Line T, Number of test cases.
In each test case, First line an integer N, length of the array.
Second line an Array A[] with N length.
1 <= T <= 100
1 <= N <= 100
1 <= A [] <= N
Output
In each test case, if array is a perumation of N print YES ,otherwise print NO .
Sample
Input | Output |
---|---|
|
|
Sample test case explaination :
First test case, N = 4 and A [] = { 2, 1, 4, 3}.
There are exactly each number from 1 to N, once in the array. So print YES.
Second test case , N = 3, A [] = { 1, 1, 2}.
Number 3 missing and 1 twice in the array, it's not permutation of N. So print NO.
Information
- ID
- 1055
- Difficulty
- 2
- Category
- Beginners Click to Show
- Tags
- (None)
- # Submissions
- 99
- Accepted
- 58
- Accepted Ratio
- 59%
- Uploaded By
Related
In following contests: