<p>Given an integer array <code>nums</code>, return <em>the largest perimeter of a triangle with a non-zero area, formed from three of these lengths</em>. If it is impossible to form any triangle of a non-zero area, return <code>0</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [2,1,2]
<strong>Output:</strong> 5
<strong>Explanation:</strong> You can form a triangle with three side lengths: 1, 2, and 2.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,2,1,10]
<strong>Output:</strong> 0
<strong>Explanation:</strong> 
You cannot use the side lengths 1, 1, and 2 to form a triangle.
You cannot use the side lengths 1, 1, and 10 to form a triangle.
You cannot use the side lengths 1, 2, and 10 to form a triangle.
As we cannot use any three side lengths to form a triangle of non-zero area, we return 0.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>3 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
	<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
</ul>

class Solution:
    def largestPerimeter(self, nums: List[int]) -> int:
        nums.sort(reverse = True)
        lNums = len(nums)
        for c in range(lNums - 2):
            # cS = nums[c]
            if nums[c] < nums[c+1] + nums[c+2]:
                return nums[c+2] + nums[c+1] + nums[c]
            # for b in reversed(range(1,c)):
            #     bS = nums[b]
            #     bc = bS + cS
            #     for a in reversed(range(b)):
            #         aS = nums[a]
            #         if bc <= aS:
            #             continue
            #         ac = aS + cS
            #         if ac <= bS:
            #             continue
            #         ab = aS + bS
            #         if ab <= cS:
            #             continue
            #         return bc + aS
        return 0

        # lNums = len(nums)
        # maxPer = 0
        # for a in range(lNums - 2):
        #     aS = nums[a]
        #     for b in range(a + 1,lNums - 1):
        #         bS = nums[b]
        #         ab = aS + bS
        #         for c in range(b + 1, lNums):
        #             cS = nums[c]
        #             if ab + cS <= maxPer:
        #                 continue
        #             if ab <= cS:
        #                 continue
        #             ac = aS + cS
        #             if ac <= bS:
        #                 continue
        #             bc = bS + cS
        #             if bc <= aS:
        #                 continue
        #             # if ab + cS > maxPer:
        #             maxPer = ab+cS
        # return maxPer
                    

17500