Count Triplets

Problem Overview

  • Count index triplets (a, b, c) in an array where d[a] < d[b] < d[c] and d[a] + d[b] + d[c] ≤ t.
  • Input: integer threshold t and array d of n distinct integers; Output: long integer count of valid triplets.
  • Constraints: 0 ≤ d[i] ≤ 1e9, 0 < t < 3e9; domain: array processing and combinatorics under a sum threshold.
  • From Citadel interviews: a coding interview problem and interview question assessing ordered indices and sums.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: