heights. The trail counts as a "single peak" when:
- it has at least three points;
- the altitudes first strictly increase and then strictly decrease;
- both the climb and the descent are non-empty, so the summit is neither the first nor the last point.
Flat stretches (two neighbouring points at the same altitude) are not allowed. Return True if the trail is a single peak, and False otherwise.heights=[1, 4, 7, 3, 0] → True
The heights rise strictly up to 7 and then fall strictly.
heights=[2, 6, 6, 1] → False
Two neighbouring 6s make a flat stretch, which is not allowed.
heights=[3, 5, 8] → False
There is a climb but no descent.
heights=[1, 4, 7, 3, 0]
True
Run checks the first 3 tests in your browser. Submit checks all 120 tests on the server, hidden ones included.