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.
- Maximum Perimeter Triangle
- Discussions
Maximum Perimeter Triangle
Maximum Perimeter Triangle
Sort by
recency
|
110 Discussions
|
Please Login in order to post a comment
You know what? I am getting pissed off with this test taking service. I pressed the submit button, my solution passed EVERY TEST but, I received an error pop-up saying the service is having trouble submitting my Java solution. This happened several times. I have my VPN disabled. What the hell do you want from me?
Rust best solution
If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions
Python best solution
If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions
Can anyone explain why is there a need to sort the sticks array first?
You don't NEED to, but it makes the comparisons more efficient since you already know at every step in your logic which is the longest leg of the triangle and which is the shortest. Also, the longest triangle will probably be made up of the longest sticks, so by sorting you are getting to the longest sticks most efficiently.
A non-degenerate triangle is one where the sum of the lengths of any two sides is greater than the length of the remaining side.