Stock Prices

Problem Overview

  • Find the number of distinct triplets (i, j, k) with i < j < k such that arr[i] + arr[j] + arr[k] is divisible by d.
  • Input: integer array arr and integer d; Output: an integer count; Constraints: 3 ≤ n ≤ 1e3, 1 ≤ arr[i] ≤ 1e9, 2 ≤ d ≤ 1e6.
  • Domain context: stock prices over days where an investor selects three purchase days meeting the divisibility rule.
  • This Rubrik interview question is a common coding interview problem focused on combinatorial counting and divisibility.

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: