Array Permutation
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
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.
Brain Booster #3
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 9
- Start at
- 2024-05-06 15:00
- End at
- 2024-05-06 18:00
- Duration
- 3.0 hour(s)
- Host
- Partic.
- 91