problem
976. Largest Perimeter Triangle
solution:
class Solution { public: int largestPerimeter(vector<int>& A) { sort(A.begin(), A.end());//decrease. for(int i=A.size()-1; i>1; i--) { if(A[i]<A[i-1]+A[i-2]) return A[i]+A[i-1]+A[i-2]; } return 0; } };
参考
1. Leetcode_easy_976. Largest Perimeter Triangle;
完
原文地址:https://www.cnblogs.com/happyamyhope/p/11316927.html
时间: 2024-11-11 02:05:33