-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.cs
More file actions
22 lines (22 loc) · 737 Bytes
/
Solution.cs
File metadata and controls
22 lines (22 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class Solution
{
public long LargestSquareArea(int[][] bottomLeft, int[][] topRight)
{
long ans = 0;
int n = bottomLeft.Length;
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++)
{
int x1 = Math.Max(bottomLeft[i][0], bottomLeft[j][0]);
int y1 = Math.Max(bottomLeft[i][1], bottomLeft[j][1]);
int x2 = Math.Min(topRight[i][0], topRight[j][0]);
int y2 = Math.Min(topRight[i][1], topRight[j][1]);
if (x2 < x1 || y2 < y1) continue;
long e = Math.Min(x2 - x1, y2 - y1);
ans = Math.Max(ans, e * e);
}
}
return ans;
}
}