Question bank › Two Pointers
Dsa Two Pointers Easy

Music Playlist Pairs

You are given a list of music track durations and a target duration. Find the number of unique pairs of tracks (i, j) such that the total duration of music tracks i and j equals the target duration. Each duration may be used only once in a pair. Input format: - The first line contains an integer n (1 ≤ n ≤ 1000), the number of tracks. - The second line contains n space-separated integers representing the track durations. - The third line contains an integer target_duration. Output format: - Output a single integer representing the number of unique pairs. Example: Input: 5 2 3 1 0 4 4 Output: 2 (The valid pairs are (2, 2) and (1, 3))

Key concepts

two_pointershashmapscounting

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