#3583
Count Special Triplets
specialist · 915 · lc medium +31 · 47.1% accepted · 550 likes · top 32%
Description
An integer array nums is given. A triplet of indices (i, j, k) is special when:
- 0 <= i < j < k < n where n = nums.length
- nums[i] == nums[j] * 2
- nums[k] == nums[j] * 2
Count all special triplets and return the total modulo 109 + 7.
Code
1
2
3