package hackerrank;

import java.util.Arrays;
import java.util.Scanner;

/**
 * https://www.hackerrank.com/challenges/maximum-perimeter-triangle
 */
public class MaximumPerimeterTriangle {
    private static void maxPerimeterTriangle(int[] array) {
        Arrays.sort(array);
        int a = array[0];
        int b = array[1];
        int c = array[array.length - 1];
        // TODO
        if (a + b > c) {
            System.out.println(a + " " + b + " " + c);
        } else {
            System.out.println("-1");
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = in.nextInt();
        }
        maxPerimeterTriangle(array);
    }
}

@@ -286,17 +286,17 @@
 int 
-a
+i
  = array
 %5B0%5D;
@@ -295,11 +295,15 @@
 rray
-%5B0%5D
+.length
 ;%0A  
@@ -312,66 +312,75 @@
     
-int b = array%5B1%5D;%0A        int c = array%5Barray.length
+while (i - 3 %3E= 0 && array%5Bi - 3%5D + array%5Bi - 2%5D %3C= array%5Bi
  - 1%5D
-;
+) %7B
 %0A   
@@ -388,15 +388,26 @@
     
-// TODO
+    i--;%0A        %7D
 %0A   
@@ -419,17 +419,18 @@
 if (
-a + b %3E c
+i - 3 %3E= 0
 ) %7B%0A
@@ -465,28 +465,61 @@
 ln(a
- + %22 %22 + b + %22 %22 + c
+rray%5Bi - 3%5D + %22 %22 + array%5Bi - 2%5D + %22 %22 + array%5Bi - 1%5D
 );%0A 

Solve Maximum Perimeter Triangle