Question bank › Two Pointers
Dsa Two Pointers Easy

Music Playlist Overlap

You are given two playlists represented as arrays of song IDs. Write a function that identifies and prints the common song IDs between the two playlists in ascending order. Each song ID is a unique non-negative integer. Input Format: The first line contains an integer n, the number of songs in the first playlist. The second line contains n space-separated integers representing the first playlist song IDs. The third line contains an integer m, the number of songs in the second playlist. The fourth line contains m space-separated integers representing the second playlist song IDs. Output Format: Print the common song IDs in ascending order on a single line, space-separated. Example: Input: 5 1 3 2 5 4 4 2 4 6 8 Output: 2 4

Key concepts

two_pointersarraysset_operations

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.