Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. Three lengths a <= b <= c form a triangle exactly when a + b > c.
Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. Three lengths a <= b <= c form a triangle exactly when a + b > c.
Example 1:
Input: {"nums":[2,2,3,4]}
Output: 3
Constraints:
1≤nums.length≤1000
0≤nums[i]≤1000
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[2,2,3,4]}
These are 4 stick lengths. Three sticks a <= b <= c close into a triangle only when a + b > c.