Sorted or Not

2.8

56 votes
Problem

In this problem you will be given an integer array A of size N, your task is find whether given array is sorted or not (in ascending order) , if print "YES" else print "NO".

Array a[n] is sorted if a[0] <= a[1] <= ... a[n - 1].

Input

First line of input contains contains integer T denoting number of test cases.
For each test case T, first line of input contains number N denoting size of array A and second line contains N space seperated integers denoting elements of array A.

Output

Print "YES" or "NO" as explained above.

Constraints

1 <= T <= 10

1 <= N <= 100,000

1 <= A[i] <= 10,00,00,00,000

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?