JAVA SIMPLE AND OPTIMIZED SOLUTION || 3 LINES OF CODE
\nclass Solution {\n    public int largestPerimeter(int[] nums) {\n        Arrays.sort(nums);\n        for (int i=nums.length-3; i >= 0; i--)\n            if (n
```\nclass Solution {\n    public int largestPerimeter(int[] nums) {\n        Arrays.sort(nums);\n        for (int i=nums.length-3; i >= 0; i--)\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/*\nAlternate logic is that you can also use-\nArrays.sort(nums);\n        for (int i=nums.length-3; i >= 0; i--)\n            if (nums[i-1] + nums[i-2] > nums[i])\n                return nums[i] + nums[i-1] + nums[i-2];\n        return 0;*/\n\n```
['Array', 'Java']