bool isMonotonic(nums) returns true if the array nums is monotonic, and false otherwise.
An array is monotonic if it is either monotone increasing or monotone decreasing.
An array is monotone increasing if for every i such that 0 <= i < nums.length - 1, nums[i] <= nums[i + 1].
An array is monotone decreasing if for every i such that 0 <= i < nums.length - 1, nums[i] >= nums[i + 1].
Note: An array with one element is monotonic.
Constraints:
nums.length
nums[i]
bool isMonotonic(nums) returns true if the array nums is monotonic, and false otherwise.
An array is monotonic if it is either monotone increasing or monotone decreasing.
An array is monotone increasing if for every i such that 0 <= i < nums.length - 1, nums[i] <= nums[i + 1].
An array is monotone decreasing if for every i such that 0 <= i < nums.length - 1, nums[i] >= nums[i + 1].
Note: An array with one element is monotonic.
Constraints:
nums.length
nums[i]