Welcome folks today in this post we will be checking whether an
array is monotonic or not in python. All the full source code of the application is shown below.
In order to get started you need to make an
app.py file and copy paste the following code
# Python3 program to find sum in Nth group # Check if given array is Monotonic def isMonotonic(A): return (all(A[i] <= A[i + 1] for i in range(len(A) - 1)) or all(A[i] >= A[i + 1] for i in range(len(A) - 1))) # Driver program A = [6, 5, 4, 4] # Print required result print(isMonotonic(A)) # This code is written by
Now if you execute the
python script by typing the below command as shown below