Skip to content

Commit 876ab69

Browse files
committed
Create 2971-find-polygon-with-the-largest-perimeter.java
1 parent bf0a87e commit 876ab69

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class Solution {
2+
3+
public long largestPerimeter(int[] nums) {
4+
Arrays.sort(nums);
5+
long res = -1, amt = 0;
6+
7+
for (int i : nums) {
8+
if (amt > i)
9+
res = amt + i;
10+
amt += i;
11+
}
12+
13+
return res;
14+
}
15+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy