Question bank › Two Pointers
Dsa Two Pointers Easy

Electronic Rhythm Sync

In a rhythm game, a player taps at certain timestamps, and the song has notes at specific timestamps. A tap matches a note if the absolute difference between their timestamps is at most K. Each tap can only be used for one note, and each note can only be used for one tap. Given two sorted arrays of timestamps, find the maximum number of matches. Input Format: Line 1: N (taps), M (notes), K (tolerance) Line 2: N sorted tap timestamps Line 3: M sorted note timestamps Example: Input: 3 3 2 10 20 30 11 18 35 Output: 2 Explanation: Tap 10 matches note 11 (|10-11|<=2). Tap 20 matches note 18 (|20-18|<=2). Tap 30 cannot match 35.

Key concepts

two_pointersgreedy

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.