Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Speedy category for Painting Wall by MBM_1607
def checkio(required, operations):
wall = []
for index, operation in enumerate(operations):
#return index + 1
wall.append(operation)
wall.sort(key=lambda operation: operation[0])
j = 0
for _ in range(len(wall) - 1):
if wall[j][1] >= wall[j+1][0]:
wall[j][1] = max(wall[j][1], wall[j+1][1])
wall.pop(j+1)
else:
j += 1
length = 0
for l in wall:
length += l[1] - l[0] + 1
if length >= required:
return index + 1
return -1
April 15, 2018
Comments: