• 문제 링크
Largest Triangle Area - LeetCode
Can you solve this real interview question? Largest Triangle Area - Given an array of points on the X-Y plane points where points[i] = [xi, yi], return the area of the largest triangle that can be formed by any three different points. Answers within 10-5 o
leetcode.com
• 풀이 코드
public class Solution {
public double largestTriangleArea(int[][] points) {
double max = 0;
for (int i = 0, n = points.length; i < n; i++)
for (int j = i + 1; j < n; j++)
for (int k = j + 1; k < n; k++)
max = Math.max(max, 0.5 * Math.abs(points[i][0] * (points[j][1] - points[k][1]) + points[j][0] * (points[k][1] - points[i][1]) + points[k][0] * (points[i][1] - points[j][1])));
return max;
}
}'Problem Solving > LeetCode' 카테고리의 다른 글
| [LeetCode] 821. Shortest Distance to a Character - Java (0) | 2026.10.20 |
|---|---|
| [LeetCode] 819. Most Common Word - Java (0) | 2026.10.19 |
| [LeetCode] 806. Number of Lines To Write String - Java (0) | 2026.10.17 |
| [LeetCode] 804. Unique Morse Code Words - Java (0) | 2026.10.16 |
| [LeetCode] 796. Rotate String - Java (0) | 2026.10.15 |
댓글