A night procession winds through town carrying n paper lanterns in a single file, numbered 0 to n-1 from front to back. Each lantern has a brightness value. Local superstition says a lantern is "glow-shielded" if the lantern immediately in front of it (the lantern with the previous index) burns brighter than a given glare threshold g. The very first lantern in the line has nothing in front of it, so it is never glow-shielded. Given every lantern's brightness and the threshold, find every glow-shielded lantern.
n and g.n integers, the brightness values of the lanterns in order, brightness[0] through brightness[n-1].Print the 0-indexed positions of every glow-shielded lantern, in increasing order, separated by single spaces on one line. If no lantern is glow-shielded, print an empty line.
Example 1
Input
5 10 20 5 15 8 30
Expected
1 3
Explanation
Lantern 0 has brightness 20 > 10, so lantern 1 is glow-shielded. Lantern 1 has brightness 5, not > 10, so lantern 2 is not shielded. Lantern 2 has brightness 15 > 10, so lantern 3 is shielded. Lantern 3 has brightness 8, not > 10, so lantern 4 is not shielded. The shielded positions are 1 and 3.
Example 2
Input
4 100 5 5 5 5
Expected
(empty)Explanation
Every brightness value is 5, and none of them exceeds the threshold 100, so no lantern is ever glow-shielded and the output line is empty.
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 →