The given 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].

A.I. Evaluation of the Solution

The candidate's solution is correct and solves the problem. The candidate's approach is also optimal, as they only iterate through the array once.

Evaluated at: 2022-11-18 23:28:35