Horje
976. Largest Perimeter Triangle leetcode solution in c++ Code Example
976. Largest Perimeter Triangle leetcode solution in c++
class Solution {
public:
    int largestPerimeter(vector<int>& nums) {
        sort(nums.begin(),nums.end());
        for(int i=nums.size()-3;i>=0;i--)
        {
            if(nums[i]+nums[i+1]>nums[i+2])
                return nums[i] + nums[i+1] + nums[i+2];
        }
        return 0;
    }
};




Cpp

Related
convert c++ code to c online Code Example convert c++ code to c online Code Example
javascript if else exercises Code Example javascript if else exercises Code Example
Polycarp found a rectangular table consisting of n rows and m columns. He noticed that each cell of the table has its number, obtained by the following algorithm "by columns": codeforces solu Polycarp found a rectangular table consisting of n rows and m columns. He noticed that each cell of the table has its number, obtained by the following algorithm "by columns": codeforces solu
sort(arr arr+n) in c++ Code Example sort(arr arr+n) in c++ Code Example
c++ main function parameters Code Example c++ main function parameters Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10