Ctrl K

Badge Swipe Alarm

Medium
Doors in a coworking space open with electronic badges. The system logs every swipe: names[i] is the badge owner's name and times[i] is the time of the swipe as "HH:MM" (24-hour clock). All records belong to the same day and come in no particular order. The system raises an alarm for a person who swiped **three or more times within one hour**, meaning at most 60 minutes pass between the first and the last of those swipes. For example, "10:00" and "11:00" fit within an hour, while "22:51" and "23:52" do not. Return the names of everyone who triggered the alarm, without duplicates, in alphabetical order.
Example 1
names=['vera', 'oleg', 'vera', 'oleg', 'vera', 'oleg'], times=['08:30', '09:00', '09:10', '09:45', '09:30', '10:01'] → ['vera']

vera swiped at 08:30, 09:10 and 09:30, all three within 60 minutes. oleg's first and third swipes are 61 minutes apart, so no alarm for him.

Example 2
names=['kim', 'kim', 'kim', 'ann', 'ann', 'ann'], times=['23:00', '00:10', '23:59', '13:00', '13:30', '14:00'] → ['ann']

All times belong to one day, so 00:10 is early morning, not the next day: kim gets no alarm. ann's 13:00 and 14:00 are exactly an hour apart, which still counts.

Constraints
  • 1 ≤ len(names) ≤ 10⁵
  • len(times) == len(names)
  • times[i] looks like "HH:MM" with 00 ≤ HH ≤ 23 and 00 ≤ MM ≤ 59
  • 1 ≤ len(names[i]) ≤ 10, lowercase English letters only
  • No pair (names[i], times[i]) appears twice
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsAnagram Buckets MediumA Subsequence of One Word Only MediumMost Searched Words MediumWord Grown Letter by Letter MediumMerge Contact Cards Medium
loading Python…
Input
names=['vera', 'oleg', 'vera', 'oleg', 'vera', 'oleg'], times=['08:30', '09:00', '09:10', '09:45', '09:30', '10:01']
Expected
['vera']

Run checks the first 3 tests in your browser. Submit checks all 109 tests on the server, hidden ones included.