Tap here to switch tabs
Problem
Submissions

Problem: Number of Divisible Triplet Sums

med
30 min
Try to solve the Number of Divisible Triplet Sums problem.

Statement

Given an integer array nums and an integer d, count the number of index triplets (i, j, k) such that i<j<ki < j < k and the sum nums[i] + nums[j] + nums[k] is divisible by d.

Return the total number of such triplets.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq d ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Divisible Triplet Sums

med
30 min
Try to solve the Number of Divisible Triplet Sums problem.

Statement

Given an integer array nums and an integer d, count the number of index triplets (i, j, k) such that i<j<ki < j < k and the sum nums[i] + nums[j] + nums[k] is divisible by d.

Return the total number of such triplets.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq d ≤109\leq 10^9