Get Distinct Pairs (Also apply to AS intern)

Amazon coding interview problem from real Amazon interviews: Given an array of AWS stock profits and a target profit, count the number of distinct pairs of stocks whose profits sum exactly to the target. Distinct pairs differ in at least one element. Return the total number of pairs. A concise interview question on arrays and pair counting.

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: