#K94047. Palindrome Array Checker
Palindrome Array Checker
Palindrome Array Checker
In this problem, you are given several test cases. For each test case, you receive an array of integers where the first integer indicates the number of elements in the array, followed by the array elements. Your task is to determine whether each array is a palindrome.
An array A of length N is said to be a palindrome if it reads the same forwards and backwards. In mathematical terms, the condition is:
$$A[i] = A[N-i+1] \quad \text{for } 1 \leq i \leq N$$
For each test case, you should output YES if the array is a palindrome, and NO otherwise.
inputFormat
The input is read from standard input (stdin) and is structured as follows:
- The first line contains an integer T, the number of test cases.
- Each of the next T lines describes a test case. Each test case contains several integers: the first integer N is the number of elements in the array, followed by N space-separated integers.
outputFormat
For each test case, print a single line to standard output (stdout) containing either "YES" if the array is a palindrome, or "NO" if it is not.## sample
2
3 1 2 1
4 1 2 3 4
YES
NO
</p>