Problem Description
Given an integer array A of size N, you need to find the count of pairs (i, j) such that:
Return the count of such pairs modulo 109 + 7.
2 <= |A| <= 105
1 <= A[i] <= 109
1 <= B <= 105
First argument is an integer array A.
Second argument is an integer B.
Return the count of such pairs that's satisfies all the properties mentioned above in the statement, modulo 109 + 7.
Input 1:
A = [1, 2, 1, 3, 1, 4] B = 2
Input 2:
A = [12, 11, 8, 1] B = 14
Output 1:
2
Output 2:
0
Explanation 1:
First pair is (0, 2) as A[0] = A[2] and (2 - 0) <= 2 Second pair is (2, 4)
Explanation 2:
No such pair possible as all elements are distinct.
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.