Counting Triplets

Asked at Demonware · Coding Questions · Difficulty: Medium · Last asked Jul 15, 2026

Given an array of integers `arr` and an integer `d`. Count the number of distinct triplets `(i, j, k)` such that `0 < i < j < k` and `(a[i] + a[j] + a[k])` is divisible by `d`. Return the number of distinct triplets.

Loading the problem…