class Solution {
public:
int largestPerimeter(vector<int>& A) {
sort(A.begin(), A.end());
int _min = 0, _max = 0;
for (int i = A.size() - 1; i > 1; --i) {
int first = A[i], second = A[i - 1];
int pos_three = i - 2;
_min = abs(first - second), _max = first + second;
if (A[pos_three] <= _min && pos_three == 0)
return 0;
else if (A[pos_three] > _min)
return first + second + A[pos_three];
}
}
};
版权声明:本文为kongqingxin12原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。