Detect Repeated MagicBand Taps at the Same Park Gate
Last updated: November 29, 2026
Quick Overview
Given a time-ordered list of MagicBand taps as (band_id, gate_id, timestamp_seconds) and a window k, return the band ids that tapped the same gate twice within k seconds, in the order they were first flagged.
Disney
November 29, 20260
0
0 solved
Given a time-ordered list of MagicBand taps as (band_id, gate_id, timestamp_seconds) and a window k, return the band ids that tapped the same gate twice within k seconds, in the order they were first flagged.
A warm-up in the style of Disney Parks technology phone screens, where entry gates, ride merge points and resort doors all consume tap events from MagicBands and MagicMobile. The interviewer checks that you key the hash map on the right pair and keep the pass linear.
What the Interviewer Expects
- Key state on the (band, gate) pair rather than the band alone
- Keep only the last timestamp per key for O(1) checks
- Flag each band once and preserve first-flagged order
- Clarify whether the window boundary is inclusive
- State O(n) time and the memory bound
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Taps arrive out of order by up to 2 seconds; how do you adapt?
- How would you expire stale keys so memory stays bounded for a full park day?
- How would you run this across thousands of gates feeding a stream processor?
- What if a double tap is legitimate, such as a parent tapping for a child band?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input is sorted by timestamp. A repeat means the same band at the same gate with a gap of at most k seconds (I will confirm inclusive). Output is each offending band id once, in the order it was fir...
High-Level Design
Scan once and keep last_seen[(band, gate)] = timestamp. For each tap, look up the previous tap for the same pair; if the gap is within k, flag the band unless it is already flagged. Always overwri...