You are viewing a single comment's thread. Return to all comments →
def maximumPerimeterTriangle(sticks): if not sticks or len(sticks)<3: return [-1] sticks.sort() maximum = len(sticks)-1 mostLeft = len(sticks)-3 while(mostLeft >=0): leftSide = sticks[mostLeft] + sticks[mostLeft+1] if (leftSide <= sticks[maximum]): maximum-=1 mostLeft-=1 else: return [sticks[mostLeft], sticks[mostLeft+1], sticks[maximum]] return [-1]
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Perimeter Triangle
You are viewing a single comment's thread. Return to all comments →