Dsa
Two Pointers
Medium
Unique Transaction Pairs
You are tasked with analyzing transaction data for unique pairs of users who have completed transactions with the same amount. Given a list of transactions represented as integers, find how many unique user pairs (i, j) exist such that the transaction amounts are the same for both users, and i != j.
Input: The first line contains an integer n (1 <= n <= 100,000), the number of transactions. The second line contains n space-separated integers representing the transaction amounts.
Output: Print a single integer representing the number of unique pairs of users.
Example:
Input:
5
100 200 100 300 200
Output:
3
Key concepts
two_pointerssetshashing
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now