C++ || simple || easy to understand
\nclass Solution {\npublic:\n    int largestPerimeter(vector<int>& nums) {\n        //select largest three that can form a triangle\n        sort(nums.begin(),n
```\nclass Solution {\npublic:\n    int largestPerimeter(vector<int>& nums) {\n        //select largest three that can form a triangle\n        sort(nums.begin(),nums.end());\n        //triangle property -> sum of smaller two > largest\n        // first valid triplet from end will give maximum perimeter\n        //other can not give maximum answer\n        for(int i=nums.size()-1;i>=2;i--)\n        {\n            int a=nums[i-2];\n            int b=nums[i-1];\n            int c=nums[i];\n            if(a+b>c) return a+b+c;\n        }\n        return 0;\n    }\n};\n```
['Greedy', 'Sorting']