# check adjacent list elements to determine if the array is monotone increasing (or decreasing)
def strictly_increasing(lst):
return all(x < y for x, y in zip(lst, lst[1:]))
def strictly_decreasing(lst):
return all(x > y for x, y in zip(lst, lst[1:]))
def isMonotonic(lst):
return strictly_increasing(lst) or strictly_decreasing(lst)
lst = [1, 3, 4, 6, 8, 9, 11, 17, 18]
print(isMonotonic(lst))
'''
run:
True
'''