Skip to content

Instantly share code, notes, and snippets.

@manojjha
Created December 30, 2022 05:48
Show Gist options
  • Save manojjha/3e6aba645172600166bb463a2980968d to your computer and use it in GitHub Desktop.
Save manojjha/3e6aba645172600166bb463a2980968d to your computer and use it in GitHub Desktop.
Find if array is in increasing order or decreasing order in python
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