Dsa
Hashing
Easy
Satellite Signal Deduplication
A satellite ground station receives signals in the format: `timestamp sensor_id value`. Due to orbital reflections, some signals are retransmitted. A signal is considered a 'retransmission' if a signal with the exact same `sensor_id` and `value` was received within `T` seconds (inclusive) before the current signal. Count the total number of retransmissions.
Input Format:
The first line contains an integer T (the time window).
Each following line contains an integer timestamp, a string sensor_id, and an integer value.
Output Format:
An integer representing the total number of retransmission signals.
Example:
Input:
5
10 S1 100
12 S1 100
20 S1 100
22 S1 100
Output:
2
(Explanation: Signal at 12 is a retransmission of 10 [12-10=2 <= 5]. Signal at 22 is a retransmission of 20 [22-20=2 <= 5]. Signal at 20 is NOT a retransmission of 12 [20-12=8 > 5].)
Key concepts
hashingtime-windowsliding logic
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