📜  检查数组是否是单调的python代码示例

📅  最后修改于: 2022-03-11 14:46:17.625000             🧑  作者: Mango

代码示例1
def strictly_increasing(L):
    return all(xy for x, y in zip(L, L[1:]))

def non_increasing(L):
    return all(x>=y for x, y in zip(L, L[1:]))

def non_decreasing(L):
    return all(x<=y for x, y in zip(L, L[1:]))

def monotonic(L):
    return non_increasing(L) or non_decreasing(L)