package leetcode;

/**
 * https://leetcode.com/problems/largest-perimeter-triangle/
 */
public class Problem976 {
    public int largestPerimeter(int[] A) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem976 prob = new Problem976();
        System.out.println(prob.largestPerimeter(new int[]{2, 1, 2})); // 5
        System.out.println(prob.largestPerimeter(new int[]{1, 2, 1})); // 0
        System.out.println(prob.largestPerimeter(new int[]{3, 2, 3, 4})); // 10
        System.out.println(prob.largestPerimeter(new int[]{3, 6, 2, 3})); // 8
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -188,440 +188,237 @@
     
-// TODO%0A        return 0;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem976 prob = new Problem976();%0A        System.out.println(prob.largestPerimeter(new int%5B%5D%7B2, 1, 2%7D)); // 5%0A        System.out.println(prob.largestPerimeter(new int%5B%5D%7B1, 2, 1%7D)); // 0%0A        System.out.println(prob.largestPerimeter(new int%5B%5D%7B3, 2, 3, 4%7D)); // 10%0A        System.out.println(prob.largestPerimeter(new int%5B%5D%7B3, 6, 2, 3%7D)); // 8
+Arrays.sort(A);%0A        for (int i = A.length - 3; i %3E= 0; i--) %7B%0A            // a + b %3E c%0A            if (A%5Bi%5D + A%5Bi + 1%5D %3E A%5Bi + 2%5D) %7B%0A                return A%5Bi%5D + A%5Bi + 1%5D + A%5Bi + 2%5D;%0A            %7D%0A        %7D%0A        return 0;
 %0A   

Solve problem 976