Leetcode 932 Solution
This article provides solution to leetcode question 932 (monotonic-array)
Access this page by simply typing in "lcs 932" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/monotonic-array
Solution
class Solution(object):
def isMonoIncreasing(self, A):
for i in range(len(A) - 1):
if A[i] > A[i + 1]:
return False
return True
def isMonoDecreasing(self, A):
for i in range(len(A) - 1):
if A[i] < A[i + 1]:
return False
return True
def isMonotonic(self, A):
"""
:type A: List[int]
:rtype: bool
"""
return self.isMonoIncreasing(A) or self.isMonoDecreasing(A)