Dsa
Two Pointers
Easy
Perfect Pairing
You have a list of integers representing a collection of items with specific values. Your goal is to find pairs of these items that add up to a specified target sum. Print the total number of unique pairs found. Each pair (i, j) is considered the same as (j, i).
Input Format:
- First line contains space-separated integers representing the item values.
- Second line contains a single integer target representing the sum.
Output Format:
- A single integer representing the total number of unique pairs that add up to the target sum.
Example:
Input:
1 2 3 4 5
5
Output:
2
Key concepts
two_pointersarrayshash_map
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