An array is monotonic if it is either monotone increasing or monotone decreasing.
An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monotone decreasing if for all i <= j, A[i] >= A[j].
Return true if and only if the given array A is monotonic.
判断一个数列是否单调,on直接做就行
class Solution(object): def isMonotonic(self, A): """ :type A: List[int] :rtype: bool """ incre = True descre = True for i in range(1, len(A), 1): if A[i] < A[i - 1]: incre = False if A[i] > A[i - 1]: descre = False return incre | descre