Two method||C++ Explanation Solution ||Sorting ||Greedy
Approach 1\n\n      int largestPerimeter(vector& nums) {\n        //sort the vector\n        sort(nums.begin(),nums.end());\n        //any tringle sum of smalle
**Approach 1**\n\n      int largestPerimeter(vector<int>& nums) {\n        //sort the vector\n        sort(nums.begin(),nums.end());\n        //any tringle sum of smaller two side greater than 3rd side...so we check that condition, a+b>c where a<b<c\n        int maxPerimeter=0;\n        \n        for(int i=0;i<=nums.size()-3;i++){\n            //check the triangle valid condition\n            if(nums[i]+nums[i+1]>nums[i+2]){\n                maxPerimeter=max(maxPerimeter,nums[i]+nums[i+1]+nums[i+2]); //find max\n            }\n        }\n        \n        return maxPerimeter; //return the result\n    }\n\t\n\t\n\t\n**Approach 2 : Sort the array**\n**We know that max value gives maximum perimeter...so use greedy method...choose element from the last and if valid triangle then return the value**\n\n\n\n        int largestPerimeter(vector<int>& nums) {\n        //sort the vector\n        sort(nums.begin(),nums.end());\n        //any tringle sum of smaller two side greater than 3rd side...so we check that condition, a+b>c where a<b<c\n        \n        \n        for(int i=nums.size()-1;i>=2;i--){\n            //check the triangle valid condition\n            if(nums[i-1]+nums[i-2]>nums[i]){\n                return(nums[i]+nums[i-1]+nums[i-2]); //perimeter\n            }\n        }\n        \n        return 0; //return 0\n    }
['C', 'Sorting', 'C++']