Tap here to switch tabs
Problem
Submissions

Problem: Count Special Triplets

med
30 min
Try to solve the Count Special Triplets problem.

Statement

Given an integer array nums, return the total number of special triplets (i, j, k).

A triplet of indices (i, j, k) is called special if all the following conditions are satisfied:

  • 0≤i<j<k<0 \leq i < j < k < nums.length

  • nums[i] =2imes= 2 imes nums[j]

  • nums[k] =2imes= 2 imes nums[j]

Constraints:

  • 3≤n==3 \leq n == nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Special Triplets

med
30 min
Try to solve the Count Special Triplets problem.

Statement

Given an integer array nums, return the total number of special triplets (i, j, k).

A triplet of indices (i, j, k) is called special if all the following conditions are satisfied:

  • 0≤i<j<k<0 \leq i < j < k < nums.length

  • nums[i] =2imes= 2 imes nums[j]

  • nums[k] =2imes= 2 imes nums[j]

Constraints:

  • 3≤n==3 \leq n == nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤105\leq 10^5