Advertisement
anhkiet2507

Untitled

Sep 20th, 2022
1,445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. package com.kietna.codeultimate;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class main {
  6.     public static void main(String[] args){
  7.        Scanner cin = new Scanner(System.in);
  8.        int t = cin.nextInt();
  9.        while(t > 0){
  10.           int n = cin.nextInt();
  11.           boolean flag = true;
  12.           int arr[] = new int[100];
  13.           for(int i = 0; i < n; i++){
  14.               arr[i] = cin.nextInt();
  15.           }
  16.           for(int i = 0; i < n/2; i++){
  17.               if(arr[i]!=arr[n-1-i]){
  18.                   flag = false;
  19.               }
  20.           }
  21.           if(flag){
  22.               System.out.println("YES");
  23.           }else{
  24.               System.out.println("NO");
  25.           }
  26.           t = t - 1;
  27.        }
  28.        
  29.  
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement