Count Special Triplets
You are given an integer array nums.
A special triplet is defined as a triplet of indices (i, j, k) such that:
0 <= i < j < k < n, wheren = nums.lengthnums[i] == nums[j] * 2nums[k] == nums[j] * 2
Return the total number of special triplets in the array.
Since the answer may be large, return it modulo 10^9 + 7.
Example 1
Input
nums = [6,3,6]Output
1The only special triplet is
(i, j, k) = (0, 1, 2), where nums[0] = nums[1] * 2 = nums[2] = 6.Example 2
Input
nums = [0,1,0,0]Output
1The only special triplet is
(i, j, k) = (0, 2, 3), where all three values are 0 and 0 = 0 * 2.Constraints
- 3 <= n == nums.length <= 10^5
- 0 <= nums[i] <= 10^5