Question bank › Two Pointers
Dsa Two Pointers Easy

Distinct Pairs With Sum

You are given an array of integers and a target sum. Write a function that finds all distinct pairs of integers whose sum equals the target sum and prints them in ascending order. Input Format: The first line contains an integer n, the number of integers. The second line contains n space-separated integers. The third line contains the target sum. Output Format: Print each distinct pair in ascending order on separate lines. Example: Input: 6 1 2 3 4 5 6 7 Output: 1 6 2 5 3 4

Key concepts

two_pointerssetsarrays

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.