Water containers up to 11-

Title: Given an array, representing the height of the wood. Pick two planks, seeking the most abundant water two planks.

def max_area(arrys):
    l,r = 0,len(arrys)-1
    res = 0
    while l<r:
        contain = min(arrys[l],arrys[r])*(r-l)
        if contain>res:
            res = contain
        if arrys[l]<arrys[r]:
            l+=1
        else:
            r-=1
    return res

  NOTE: before and after movement of the pointer to the intermediate two strategies for maximum storage capacity. Moving pointer movement policy short side of the board.

Guess you like

Origin www.cnblogs.com/kingshine007/p/11518908.html