Array Mirror

Problem Statement

Given an array of integers, determine if the array is the same when read forwards and backward.


Input Format:

  • The first line contains an integer T, the number of test cases (1 ≤ T ≤ 103).
  • The first line of each test case contains two space-separated integers N (1 ≤ N ≤ 105) and the number of elements in the array, and Ai (1 ≤ Ai ≤ 105), the elements of the array.

Output Format:

  • For each test case, print “YES” if the array elements are the same when read forwards and backwards. Otherwise, print “NO”.

Constraints:

  • The array contains only integers.
Sample Input
Sample Output

Explanation:

  • In the first test case, the array {1, 2, 3, 2, 1} is the same when read forwards and backward.
  • In the second test case, the array {1, 2, 3, 4} is not the same when read forwards and backward.

Solution

file_type_python array_mirror.py
# write your code here

Comments

Load Comments