Logic =>      We can have atmost 2 distinct numbers if we have 1 distinct number then whole array is same or arr[0] == arr[n-1] [1,1,1,1] = [1,1,1,1] = [1] [1,2,3,1] = [1,1,1,1] = [1] If we have 2 distinct number then whole array then array will be divided into two parts =>  [1,2,3,1,5,6,8,5] = [1,1,1,1,5,5,5,5] = [1,5]     Conditions => if a[0] == a[n-1] then yes else  for(int i = 1 ; i < n ; i++){ if(arr[0] == arr[i] & arr[i+1] == arr[n-1] then YES then NO CODE =  # include  < stdio.h > # include  < stdlib.h > int  main ( void ) {         int  t ;     scanf (" %d ", & t );         while ( t -- ){                 int  n ;         scanf (" %d ", & n );                 int  arr [ n ];         for ( int  i  =  0  ; i  <  n  ; i ++ ){ ...