You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution, you can watch the explanation here : https://youtu.be/cP4PLTgC1OE
vector<int> maximumPerimeterTriangle(vector<int> sticks) { sort(sticks.begin(), sticks.end()); for(int i = sticks.size() - 1; i >= 2; i--){ if(sticks[i] < sticks[i - 1] + sticks[i - 2]) return {sticks[i - 2], sticks[i -1], sticks[i] }; } 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 →
Here is my c++ solution, you can watch the explanation here : https://youtu.be/cP4PLTgC1OE