Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Creative category for Garland by Tinus_Trotyl
def illuminate_all(lights: list[int]) -> int:
begin, lamps = 0, 0
while begin < len(lights):
step = 0
for i, light in enumerate(lights):
step = i - begin + light + 1 if 0 <= begin + light - i < 2 * light - step + 1 else step
begin, lamps = begin + step, lamps + 1
return lamps
Aug. 2, 2023
Comments: