Skip to content

Commit 1c3246b

Browse files
add 3000
1 parent b6934ae commit 1c3246b

File tree

2 files changed

+23
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src/main/java/com/fishercoder/solutions/fourththousand

2 files changed

+23
-0
lines changed

Diff for: paginated_contents/algorithms/4th_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@
7171
| 3006 | [Find Beautiful Indices in the Given Array I](https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3006.java) | | Medium |
7272
| 3005 | [Count Elements With Maximum Frequency](https://leetcode.com/problems/count-elements-with-maximum-frequency/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3005.java) | | Easy |
7373
| 3004 | [Maximum Subtree of the Same Color](https://leetcode.com/problems/maximum-subtree-of-the-same-color/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3004.java) | | Medium | DFS, Tree
74+
| 3000 | [Maximum Area of Longest Diagonal Rectangle](https://leetcode.com/problems/maximum-area-of-longest-diagonal-rectangle/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3000.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
public class _3000 {
4+
public static class Solution1 {
5+
public int areaOfMaxDiagonal(int[][] dimensions) {
6+
int ans = 0;
7+
double maxDiagonal = 0.0;
8+
for (int i = 0; i < dimensions.length; i++) {
9+
int length = dimensions[i][0];
10+
int width = dimensions[i][1];
11+
double diagonal = Math.sqrt(length * length + width * width);
12+
if (diagonal > maxDiagonal) {
13+
maxDiagonal = diagonal;
14+
ans = length * width;
15+
} else if (diagonal == maxDiagonal && length * width > ans) {
16+
ans = length * width;
17+
}
18+
}
19+
return ans;
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)