Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Uncategorized category for Painting Wall by ciel
import bisect
def checkio(num,data):
if num==0: return 0
ret_idx=0
result=0
se=[]
for l,r in data:
ret_idx+=1
right_idx=bisect.bisect_left(se,[l,0]) #l <= se[right_idx][0]
if right_idx!=0:
left_idx=right_idx-1
if l<=se[left_idx][1]: # overlap with left
l=se[left_idx][0]
r=max(r,se[left_idx][1])
result-=se[left_idx][1]-se[left_idx][0]+1
se.pop(left_idx)
right_idx-=1
while right_idx
March 5, 2014
Comments: