package leetcode;

/**
 * https://leetcode.com/problems/largest-triangle-area/
 */
public class Problem812 {
    public double largestTriangleArea(int[][] points) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem812 prob = new Problem812();
        System.out.println(prob.largestTriangleArea(new int[][]{
            {0, 0}, {0, 1}, {1, 0}, {0, 2}, {2, 0}
        })); // 2
    }
}

@@ -173,260 +173,1024 @@
  // 
-TODO%0A        return 0;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem812 prob = new Problem812();%0A        System.out.println(prob.largestTriangleArea(new int%5B%5D%5B%5D%7B%0A            %7B0, 0%7D, %7B0, 1%7D, %7B1, 0%7D, %7B0, 2%7D, %7B2, 0%7D%0A        %7D)); // 2
+https://en.wikipedia.org/wiki/Heron%2527s_formula%0A        double maxArea = 0;%0A        for (int i = 0; i %3C points.length; i++) %7B%0A            for (int j = 0; j %3C points.length; j++) %7B%0A                if (j == i) %7B%0A                    continue;%0A                %7D%0A                for (int k = 0; k %3C points.length; k++) %7B%0A                    if (k == i %7C%7C k == j) %7B%0A                        continue;%0A                    %7D%0A                    double a = distance(points%5Bi%5D, points%5Bj%5D);%0A                    double b = distance(points%5Bi%5D, points%5Bk%5D);%0A                    double c = distance(points%5Bj%5D, points%5Bk%5D);%0A                    double s = (a + b + c) / 2;%0A                    double area = Math.sqrt(s * Math.abs(s - a) * Math.abs(s - b) * Math.abs(s - c));%0A                    maxArea = Math.max(maxArea, area);%0A                %7D%0A            %7D%0A        %7D%0A        return maxArea;%0A    %7D%0A%0A    private static double distance(int%5B%5D x, int%5B%5D y) %7B%0A        return Math.sqrt(Math.pow(x%5B0%5D - y%5B0%5D, 2) + Math.pow(x%5B1%5D - y%5B1%5D, 2));
 %0A   

Solve problem 812