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
Coding & Algorithms
Software Engineer
Disney
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

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
hash maps
composite keys
event streams
deduplication
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported

Related Questions