Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 555 Bytes

README.md

File metadata and controls

18 lines (12 loc) · 555 Bytes

Monotonic array

Can you check if a given array containing n integers is monotonic? Your function should return "true" if it is monotonic and "false" if it's not.

An array is monotonic if it is either monotone increasing or monotone decreasing. An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monotone decreasing if for all i <= j, A[i] >= A[j].

Examples:

Input : 6 5 4 4
Output : true

Input : 5 5 5 4
Output : true

Input : 5 15 20 10
Output : false