Skip to content

Practice Count Special Triplets

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#3583
LeetCode Problem

Count Special Triplets

Problem Statement

Count triples of indices i < j < k for which nums[i] and nums[k] both equal twice nums[j]. Return the count modulo 10^9 + 7.

Source: Count Special Triplets on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [6,3,6]
Output
1

# Example 2

Input
nums = [0,1,0,0]
Output
1

# Example 3

Input
nums = [8,4,2,8,4]
Output
2

Constraints

3 <= n == nums.length <= 10^5
0 <= nums[i] <= 10^5

Related LeetCode Problems

Practice more problems similar to Count Special Triplets.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.