MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / Solution

Class Solution

LeetCode_problems/Monotonic Array/solution_1.py:1–10  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution:
2 def isMonotonic(self, A: List[int]) -> bool:
3 #an array is monotonic if it is either increasing or decreasing, so we check if the array is equal to
4 #its sorted version in either descending order or ascending order. If yes return True
5 #else return False.
6 if A==sorted(A):
7 return True
8 if A==sorted(A,reverse=True):
9 return True
10 return False

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected