Created
December 30, 2022 05:48
-
-
Save manojjha/3e6aba645172600166bb463a2980968d to your computer and use it in GitHub Desktop.
Find if array is in increasing order or decreasing order in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def checkType(arr, n): | |
# If the first two and the last two elements | |
# of the array are in increasing order | |
if (arr[0] <= arr[1] and arr[n-2] <= arr[n-1]): | |
print("Increasing"); | |
elif (arr[0] >= arr[1] and arr[n-2] >= arr[n-1]): | |
print("Decreasing"); | |
# Driver code | |
if __name__ == "__main__" : | |
arr = [17,15,13,11,9,7,5,3] | |
n = len(arr); | |
checkType(arr, n); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment