C++ || 4 Lines || Very Very Simple Solution with Explanation
Before diving into code.. Let us recall the basic rule for lengths of sides of a triangle\ni.e, sum of any two sides of a triangle should be greater than its th
* Before diving into code.. Let us recall the **basic rule** for lengths of sides of a triangle\ni.e, sum of any two sides of a triangle should be greater than its third side.\nSimply, ` a + b > c `\n\twhere *a, b, c are sides of triangle*\n\n**Approach**:\n Since we need the largest perimter from the given nums. We sort the array and traverse from the end\n*  `if nums[i] < nums[i-1] + nums[i-2]`, then \n\t we Stop and return the perimeter==> `nums[i] + nums[i-1] + nums[i-2]`\n \n*  if there is no values that satisfies the given condition then\n\twe `return 0`\n \n**C++:**\n\n```\nint largestPerimeter(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n        for(int i = nums.size()-1; i>=2; i--)\n\t\t\t\tif(nums[i] < nums[i-1] + nums[i-2])    return nums[i] + nums[i-1] + nums[i-2];\n        return 0;\n    }\n \n```\n\n**Please UpVote Me if you like it : )**
['Math', 'Greedy', 'Sorting']