You are viewing a single comment's thread. Return to all comments →
JS solution
function maximumPerimeterTriangle(sticks) { sticks.sort((a, b) => a - b); const res = []; for (let i = 1; i < sticks.length - 1; i++) { if (sticks[i - 1] + sticks[i] > sticks[i + 1]) { res.push([sticks[i - 1], sticks[i], sticks[i + 1]]); } } return res.pop() || [-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 →
JS solution
}