#1604
Alert Using Same Key-Card Three or More Times in a One Hour Period
specialist · 990 · lc medium +32 · verified · 46.2% accepted · 338 likes · top 30%
Description
Office workers swipe key-cards throughout the day. You are given keyName and keyTime arrays, where each pair records the worker's name and swipe time in "HH:MM" format. Return a sorted list of names of workers who swiped three or more times within any 60-minute window (inclusive endpoints).
Example 1:
Input: keyName = ["daniel","daniel","daniel","luis","luis","luis","luis"], keyTime = ["10:00","10:40","11:00","09:00","11:00","13:00","15:00"]
Output: ["daniel"]
Explanation: "daniel" used the keycard 3 times in a one-hour period ("10:00","10:40", "11:00").
Example 2:
Input: keyName = ["alice","alice","alice","bob","bob","bob","bob"], keyTime = ["12:01","12:00","18:00","21:00","21:20","21:30","23:00"]
Output: ["bob"]
Explanation: "bob" used the keycard 3 times in a one-hour period ("21:00","21:20", "21:30").
Code
1
2
3