Get Discount Pairs
Problem Overview
- Count pairs (i < j) of products whose prices sum to a multiple of x.
- Input: integer x and array prices of n products; Output: number of valid pairs.
- Constraints: 1 <= x <= 2*10^9, 1 <= n <= 10^5, 1 <= prices[i] <= 9.
- Real-world e-commerce context: discount applies to qualifying product pairs.
- From Amazon interviews; a coding interview problem and common interview question.
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:
