Python Solution Falling Squares


#1

class Solution(object):
def solve(self, A):
h=[0]*len(A)
for i, (l, s) in enumerate(A):
r=l+s
h[i]+=s
for j in range(i+1,len(A)):
l2=A[j][0]
r2=l2+A[j][1]
if l2l:
h[j]=max(h[j],h[i])

    r=[]
    for i in h:
        r.append(max(r[-1],i) if r else i)
    return r