Check if an Array is Sorted
Easyjavapythonccppjavascript
Given an array of N integers, determine whether its elements are arranged in non-decreasing order.
Input Format
The first line contains an integer N. The second line contains N space-separated integers.
Output Format
Print 1 if the array is sorted in non-decreasing order, otherwise print 0.
Example 1
Input
5 1 2 2 5 8
Output
1
Explanation: Every element is <= the element after it.
- 1 <= N <= 100000
- -1000000000 <= A[i] <= 1000000000