647. Monotonic Array
0
Medium
Ram is interested in determining whether a given array is monotonic or not.
An array is considered monotonic if it is either strictly increasing or strictly decreasing.
An array nums is considered monotonic increasing if for all i <= j, nums[i] <= nums[j]. An array nums is considered monotonic decreasing if for all i <= j, nums[i] >= nums[j].
You are given an integer array nums. Write a program to determine if the given array is monotonic or not, and print **True** if it is monotonic, or **False** otherwise.
Input Format
The first line of input contains an integer N, representing the size of the array.
The second line contains N space-separated integers, representing the elements of the array.
The second line contains N space-separated integers, representing the elements of the array.
Output Format
Print "True" if the given array is monotonic, or "False" otherwise.
Example
Input
5
1 4 2 5 3
Output
False
Constraints
1 <= N <= 10000
-1000 <= nums[i] <= 1000
-1000 <= nums[i] <= 1000
Loading...
View Submissions
Console