Snackdown Round 1A

So here is the next easy one from code chef's snackdown 2019 round 1A




 for t in range(int(input())):   
   flag='1'  
   n = int(input())   
   a = list(map(int, input().split()))  
   for i in range(1,n):  
   if(a[i]>=a[i-1]):  
     pass  
   else:  
     break  
   if(i==(n-1)):  
   print("YES")  
   else:  
   for j in range(i+1,n):  
     if(a[j]>=a[j-1] and a[j]<=a[0]):  
       pass  
     else:  
       flag='0'  
       break  
   if(flag=='1'):  
     print("YES")  
   else:  
     print("NO")  

Comments

Popular Posts