Link to Question: CSES - Traffic Lights.
I’m confused regarding what the question is asking.
If we’re looking at the input: 8 3 3 6 2
I’m confused about why the output is: 5 3 3
Shouldn’t the output be: 5 3 2
Regarding the last one, there the next upcoming light is on the 3rd position, while the previous light is on the 0th position. Thus the output should be 2 right?
These 2 users had the same question, but I don’t understand their explanation:
after adding the lights, wouldn’t the result would be:
1 2 3 4 5 6 7 8
x x x
with the longest segment being from [4,5] or [7,8] which is length 2
edit: oops i misread the question (even after i solved it 2 months ago)
the traffic lights are considered as points while we’re supposed to calculate the maximum “distance” between two existing traffic lights.