You are viewing a single comment's thread. Return to all comments →
cpp solution
vector<int> maximumPerimeterTriangle(vector<int> sticks) { vector<int> ans; sort(sticks.rbegin(),sticks.rend());//reverse sorting for(int i=0;i<sticks.size()-2;i++) { if(sticks[i]<(sticks[i+1]+sticks[i+2])) { ans.push_back(sticks[i+2]); ans.push_back(sticks[i+1]); ans.push_back(sticks[i]); return ans; } } ans.push_back(-1); return ans; }
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 →
cpp solution