LeetCode 1604, "Alert Using Same Key-Card Three or More Times in a One Hour Period," matches the PayPal interview question with tags Array, Hash Table, Sorting, and Sliding Window. This problem involves identifying employees who trigger security alerts based on excessive key-card usage.
LeetCode company workers use key-cards to unlock office doors. Each time a worker uses their key-card, the security system saves the worker's name and the time of use. The system emits an alert if any worker uses the key-card three or more times in a one-hour (60-minute) period.
You are given two arrays of strings:
keyName: where keyName[i] is the name of the worker using the key-cardkeyTime: where keyTime[i] is the time (in "HH:MM" 24-hour format) when they used itAll times are from the same day. Return a list of unique worker names who received an alert, sorted in ascending alphabetical order.
Note: "10:00" to "11:00" is within one hour (exactly 60 minutes), but "22:51" to "23:52" is not (61 minutes).[1][3][5]
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").[5][6]
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"). "alice" used it 3 times but not within one hour.[6][5]
Workers with fewer than 3 uses or spread beyond 60 minutes trigger no alert, returning [].[1]
1 ≤ keyName.length, keyTime.length ≤ 10^5keyName.length == keyTime.lengthkeyTime[i] is in "HH:MM" format (00:00 ≤ HH:MM ≤ 23:59)keyName[i] length is 1-10 lowercase English lettersGroup times by name (hash table), convert "HH:MM" to minutes since midnight, sort each employee's times, then use sliding window: for sorted times t, check if any t[i+2] - t[i] ≤ 60.[1]