values. Can it be made non-decreasing by changing at most one element (to any integer)?
An array is non-decreasing when every element is at most the next one: values[i] ≤ values[i + 1] for every i from 0 to len(values) - 2.
Return True if it can, and False otherwise.values=[3, 9, 5, 6] → True
Change the 9 to, say, 4 and the array becomes [3, 4, 5, 6].
values=[6, 2, 7, 1] → False
There are two drops, 6 → 2 and 7 → 1, far enough apart that one change cannot fix both.
values=[-4, -4, 0] → True
values=[3, 9, 5, 6]
True
Run checks the first 3 tests in your browser. Submit checks all 168 tests on the server, hidden ones included.