values. Look for three elements, not necessarily adjacent but in this order, values[i], values[j], values[k] with i < j < k, such that
values[i] < values[k] < values[j].
In other words, a smaller value comes first, then the largest of the three, and the last one falls strictly between them.
Return True if such a triple exists and False otherwise.values=[6, 2, 9, 5] → True
Take 2, 9, 5: a small value, then the largest one, then one that lands between them.
values=[9, 7, 4, 4, 1] → False
The values only go down, so nothing later is ever larger and there is no peak to build on.
values=[3, 8, 3, 10] → False
3, 8, 3 does not count: the third value must be strictly greater than the first. No other triple works either.
values=[6, 2, 9, 5]
True
Run checks the first 3 tests in your browser. Submit checks all 146 tests on the server, hidden ones included.