A pyrotechnics show director reviews the altimeter trace of a single firework shell, sampled once per tick from launch to burnout. A trace is called a clean single-burst arc if the recorded heights strictly increase up to exactly one peak sample and then strictly decrease all the way to the final sample, with at least one sample on each side of the peak — the peak can never be the very first or the very last reading. Given the sequence of height samples in chronological order, determine whether it forms a clean single-burst arc.
Line 1: a single integer n — the number of height samples.
Line 2: n space-separated integers h_1 ... h_n — the recorded heights in chronological order.
Print true if the samples form a clean single-burst arc, or false otherwise.
Example 1
Input
5 2 4 7 5 1
Expected
true
Explanation
The samples 2, 4, 7 strictly increase up to the peak of 7 at index 3, and then 7, 5, 1 strictly decrease to the end. The peak sits strictly between the first and last samples, so this is a clean single-burst arc and the answer is true.
Example 2
Input
4 3 5 5 2
Expected
false
Explanation
The samples rise from 3 to 5, but then repeat the same height 5 before falling to 2. Because the two 5s form a flat plateau rather than a single strict peak, the rise-then-fall requirement is broken, so the answer is false.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →