You are viewing a single comment's thread. Return to all comments →
intuitive, efficient solution sliding window approach:
def maximumPerimeterTriangle(sticks): sticks.sort() n = len(sticks) for i in range(n - 1, 1, -1): a, b, c = sticks[i - 2], sticks[i - 1], sticks[i] if a + b > c: return [a, b, c] 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 →
intuitive, efficient solution sliding window approach: