Python, C++,Java||Faster than 99.57%||Simple-Short-Solution||Easy To Understand
Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome.\n___\n__\nQ
***Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome*.**\n___________________\n_________________\n***Q976. Largest Perimeter Triangle***\n____________________________________________________________________________________________________________________\n____________________________________________________________________________________________________________________\n\u2705 **Python  Code** :\n```\nclass Solution:\n    def largestPerimeter(self, nums: List[int]) -> int:\n        nums = sorted(nums)[::-1]\n        for i in range(len(nums) - 2):\n            if nums[i] < nums[i + 1] + nums[i + 2]:\n                return nums[i] + nums[i + 1] + nums[i + 2]\n        return 0\n```\n____________________________________________________________________________________________________________________\n____________________________________________________________________________________________________________________\n\n\u2705 **Java Code** :\n```\nclass Solution {\n    public int largestPerimeter(int[] nums) {\n        Arrays.sort(nums);\n        for(int i=nums.length-1;i>1;i--)\n        \n            if(nums[i]<nums[i-1]+nums[i-2])\n                return nums[i]+nums[i-1]+nums[i-2];\n        return 0;       \n    }\n}\n```\n\n____________________________________________________________________________________________________________________\n____________________________________________________________________________________________________________________\n\u2705 **C++  Code** :\n```\nclass Solution {\npublic:\n    int largestPerimeter(vector<int>& nums) {\n        sort(nums.begin(),nums.end());\n        int sum=0;\n        for(int i=0;i<nums.size()-2;i++){\n            if(nums[i]+nums[i+1]>nums[i+2]){\n                sum=max(sum,nums[i]+nums[i+1]+nums[i+2]);\n            }\n        }\n        return sum;\n    }\n};\n```\n____________________________________________________________________________________________________________________\n____________________________________________________________________________________________________________________\nIf you like the solution, please upvote \uD83D\uDD3C\nFor any questions, or discussions, comment below. \uD83D\uDC47\uFE0F\n
['C', 'Python', 'Java']