Tap here to switch tabs
Problem
Submissions

Problem: Number of Arithmetic Triplets

med
30 min
Try to solve the Number of Arithmetic Triplets problem.

Statement

You are given a 00 indexed, strictly increasing integer array nums and a positive integer diff.

A triplet of indices (i, j, k) is defined as an arithmetic triplet if the following conditions are satisfied:

  • i << j << k

  • nums[j] −- nums[i] == diff

  • nums[k] −- nums[j] == diff

Return the total number of unique arithmetic triplets.

Constraints:

  • 3≤3 \leq nums.length ≤200\leq 200

  • 0≤0 \leq nums[i] ≤200\leq 200

  • 1≤1 \leq diff ≤50\leq 50

  • nums is strictly increasing.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Arithmetic Triplets

med
30 min
Try to solve the Number of Arithmetic Triplets problem.

Statement

You are given a 00 indexed, strictly increasing integer array nums and a positive integer diff.

A triplet of indices (i, j, k) is defined as an arithmetic triplet if the following conditions are satisfied:

  • i << j << k

  • nums[j] −- nums[i] == diff

  • nums[k] −- nums[j] == diff

Return the total number of unique arithmetic triplets.

Constraints:

  • 3≤3 \leq nums.length ≤200\leq 200

  • 0≤0 \leq nums[i] ≤200\leq 200

  • 1≤1 \leq diff ≤50\leq 50

  • nums is strictly increasing.