How to solve Maximum Perimeter Triangle in Hackerrank
Jul 28, 2017 · 1 min read
After reading the sides of the triangle in an array, Sort them in decreasing order. Because, we need to find out the maximum perimeter.
Run a single for loop, initiating the index to zero , up to (array size - 2).
Check whether, the indexed array element is lesser than the sum of next to elements of the array.
If the condition is satisfied, print those elements in ascending order.
If the condition is not satisfied, print -1.
Here, the code written in Java 8 is attached for your reference.
Thank You, Have a good day.

Please, do comment n the post, so that I can improve.
