Largest Perimeter Triangle
Each item of nums is a stick length. Pick three sticks that can form a triangle with positive area (the two shorter sticks must add up to more than the longest). Return the biggest perimeter such a triangle can have.
Return 0 if no triangle is possible.
Example 1
nums [2,1,2]
returns 5
Sides 2, 1, 2: perimeter 5.
Example 2
nums [1,2,1,10]
returns 0
No three sticks work.
Constraints
1 <= len(nums) <= 201 <= nums[i] <= 50
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.