profile describes a mountain: its values strictly increase up to the summit and then strictly decrease. Both the climb and the descent have at least one step.
Return the index of the summit (0-based).
Scanning the whole array for the maximum is easy; solve it in O(log n).profile=[2, 5, 9, 7, 3] → 2
Heights rise to 9 at position 2 and only fall after it.
profile=[0, 4, 1] → 1
The shortest possible mountain: one step up, one step down.
profile=[1, 3, 6, 10, 15, 14] → 4
profile=[2, 5, 9, 7, 3]
2
Run checks the first 3 tests in your browser. Submit checks all 84 tests on the server, hidden ones included.