Python with heap
1) No need to sort the entire array. We need 3 largest numbers, then may be next largerst etc. Therefore we build the heap, to pre-order data only. O(n) time. T
1) No need to sort the entire array. We need 3 largest numbers, then may be next largerst etc. Therefore we build the heap, to pre-order data only. O(n) time. Though Python\'s min heap needs to negate the number, another O(n) run\n2) To check the triangle rule, no need need to check every 3 combinations of the sides a, b, c, one check is enough. if a is the largest side, then then b < a + c and c < a + b are guaranteed, only need to check if a < b + c holds true\n\n```\nfrom heapq import heapify, heappop\n\n\nclass Solution:\n    def largestPerimeter(self, A: List[int]) -> int:\n        for i, x in enumerate(A):\n            A[i] = -x\n        heapify(A)\n        \n        s0 = -heappop(A)\n        s1 = -heappop(A)\n        s2 = -heappop(A)\n        \n        try:\n            while s0 >= s1 + s2:\n                s0, s1, s2 = s1, s2, -heappop(A)\n            return s0 + s1 + s2\n        except IndexError:\n            return 0\n```
[]