Java simple solution in  O(NlogN) with easy explanation
triangle sum property is used\nwhich says side1+side2 > side3 when side3>side2>side1\n\nso to get the highest perimeter , we are first sorting the array first t
triangle sum property is used\nwhich says side1+side2 > side3 when side3>side2>side1\n\nso to get the highest perimeter , we are first sorting the array first to get the maximum elements\n\n\n```\nclass Solution {\n    public int largestPerimeter(int[] nums) {\n        Arrays.sort(nums);\n        int per=0;// case where triangle will not be formed will be handled by per=0;\n        for(int i=nums.length-1;i>=2; i--)\n        {\n            if(nums[i-1]+nums[i-2]>nums[i])\n            {\n                per=nums[i]+nums[i-1]+nums[i-2];\n                break;\n            }\n            \n        }\n        return per;\n    }\n}\n\n```
['Java']