values. Cut it at one position into two non-empty parts, left and right, so that every number in the left part is less than or equal to every number in the right part.
There may be several such cuts. Pick the one that makes the left part as short as possible and return its length.
At least one valid cut is guaranteed to exist.values=[4, 2, 7, 5, 9] → 2
The left part is [4, 2] and the right part is [7, 5, 9]: the left maximum 4 does not exceed the right minimum 5. Taking just [4] fails because 2 would end up on the right.
values=[3, 3, 1, 3, 8] → 3
The 1 must land in the left part, so the left part is [3, 3, 1]; its maximum 3 is not greater than the right minimum, also 3.
values=[0, 6] → 1
values=[4, 2, 7, 5, 9]
2
Run checks the first 3 tests in your browser. Submit checks all 81 tests on the server, hidden ones included.