Given an integer array nums, return the largest perimeter of a triangle with a non-zero area that can be formed from three of these lengths. If it is impossible to form any triangle of non-zero area, return 0.
Given an integer array nums, return the largest perimeter of a triangle with a non-zero area that can be formed from three of these lengths. If it is impossible to form any triangle of non-zero area, return 0.
Example 1:
Input: {"nums":[2,1,2]}
Output: 5
Constraints:
3≤nums.length≤104
1≤nums[i]≤106
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[2,1,2]}
We have 3 sticks. Three sticks make a real triangle only if the two shorter ones together are longer than the longest.