10032. Find Polygon With the Largest Perimeter
You are given an array of positive integers
nums
of lengthn
.A polygon is a closed plane figure that has at least
3
sides. The longest side of a polygon is smaller than the sum of its other sides.Conversely, if you have
k
(k >= 3
) positive real numbersa1
,a2
,a3
, …,ak
wherea1 <= a2 <= a3 <= ... <= ak
anda1 + a2 + a3 + ... + ak-1 > ak
, then there always exists a polygon withk
sides whose lengths area1
,a2
,a3
, …,ak
.The perimeter of a polygon is the sum of lengths of its sides.
Return the largest possible perimeter of a polygon whose sides can be formed from
nums
, or-1
if it is not possible to create a polygon.
1 | class Solution { |