We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defmaximumPerimeterTriangle(sticks):triangles=[]# Go through the numbers from largest to smallest.# Return the first non-degenerate triple found, it will be the largest.sorted_sticks=sorted(sticks)foriinreversed(range(len(sorted_sticks)-2)):side_1=sorted_sticks[i+2]side_2=sorted_sticks[i+1]side_3=sorted_sticks[i]if(side_2+side_3>side_1):returnside_3,side_2,side_1return[-1]
Cookie support is required to access HackerRank
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 →