A harbor's shipping channel is lined with n numbered marker beacons, indexed from 0 starting at the shore. Every beacon in the row is calibrated to emit light at exactly the same brightness -- except for a single beacon whose lamp has overdriven and now shines at a brightness strictly greater than all the others. You are given the brightness reading of every beacon, in order. Identify the position of the overdriven beacon.
Print a single integer: the 0-indexed position of the overdriven beacon.
Example 1
Input
5 2 2 2 7 2
Expected
3
Explanation
Every beacon reads 2 except the beacon at index 3, which reads 7 -- strictly brighter than the rest -- so the answer is 3.
Example 2
Input
3 10 5 5
Expected
0
Explanation
The common brightness shared by the other beacons is 5, and the beacon at index 0 reads 10, which is strictly greater, so the answer is 0.
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 →