python 3  ||  4 lines, geometry, w/ explanation  ||  T/S: 92% / 30%
Three line segments comprise a triangle if and only if the greatest length of the three sides is less than the sum of lengths of the other two sides. (A few ske
Three line segments comprise a triangle if and only if the greatest length of the three sides is less than the sum of lengths of the other two sides. (A few sketches or playing with three sticks should convince you of this fact.)\n\nHere\'s the Plan:\n\n- Sort `nums` in non-increasing order.\n\n- Iterate though the list and pop off the first element until `nums[0] < nums[1]+nums[2]`. The sum of these three integers is the solution.\n - If no such three numbers exist, then return 0\n```\nclass Solution:\n    def largestPerimeter(self, nums: list[int]) -> int:\n        \n        nums.sort(reverse = True)\n        \n        while len(nums) > 2 and nums[0] >= nums[1] + nums[2]:\n            nums.pop(0)\n            \n        return 0 if len(nums) < 3 else sum(nums[:3])\n```\n[https://leetcode.com/problems/largest-perimeter-triangle/submissions/1273589083/](https://leetcode.com/problems/largest-perimeter-triangle/submissions/1273589083/)\n\nI could be wrong, but I think that time complexity is *O*(*N* log *N*) and space complexity is *O*(1), in which *N* ~ `len(nums)`.
['Python']