You are viewing a single comment's thread. Return to all comments →
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions/tree/master , feel free to give a star :) )
std::vector<int> maximumPerimeterTriangle( std::vector<int> _sticks ){ std::sort( _sticks.begin(), _sticks.end(), std::greater<int>() ); for(auto itBeg = _sticks.cbegin(), itEnd = itBeg + 3; itEnd != _sticks.cend() + 1; ++itBeg, ++itEnd ){ if(*itBeg < *(itBeg + 1) + *(itBeg + 2)){ return {*(itBeg + 2), *(itBeg + 1), *itBeg}; } } 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 →
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions/tree/master , feel free to give a star :) )