You are given an array of N
non-negative integers, A0, A1,..., AN-1
Considering each array element Ai
as the edge length of some line segment, count the number of triangles that you can form using these array values.Notes:
- You can use any value only once while forming each triangle. The order of choosing the edge lengths doesn't matter. Any triangle formed should have a positive area.
- Return answer modulo 109 + 7.
1 <= |A| <= 105Input Format
0 <= Ai <= 106
The first argument is an integer array A.Output Format
Return an integer equal to the count of the number of triangles that you can form.Example Input
A = [1, 1, 1, 2, 2]Example Output
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified.
Still have a question? Checkout Sample Codes for more details.