Topics

# Alert Using Same Key-Card More than Two Times in a One Hour Period

Easy
0/40
Average time to solve is 20m
Contributed by
1 upvote

## Problem statement

The office doors can only be open by using the ‘key-cards’ given to the workers. Whenever a worker uses their ‘key-card’ to unlock the door, the office’s security system saves his name and the time when he used it in ‘any order’. The security system programmed in such a way that, if any worker uses the ‘key-card’ strictly “more than two times in one hour”, then the system emits an ‘alert’.

You are given two string arrays ‘keyName’, and ‘keyTime’, denoting the ‘name’ and the ‘time’ of the worker when he used his ‘key-card’ in a “single day”. Your task is to find the list of “unique worker” names who received an ‘alert’.

Note:

``````1. The ‘keyName’ contains only the lower-case English alphabets.

2. The ‘keyTime’ is given in the 24-hour format “HH:MM”, such as “00:00”, “13:35”, and “23:59” are some of the valid times.

3. “08:05 - 09:05” is considered to be within a ‘one-hour’, whereas “12:05 - 13:06” is not considered to be within a ‘one-hour’ period.

4. The system saves the ‘name’ and the ‘time’ of the workers in ‘any order’.

5. Each pair of [‘keyName’, ‘keyTime’] is ‘unique’.

6. Print the output in ‘increasing’ order alphabetically.
``````
Detailed explanation ( Input/output format, Notes, Images )
Constraints:
``````1 <= ‘T’ <= 10
1 <= ‘N’ <= 10^4
1 <= ‘keyName[i].length’ <= 10
“00:00” <= ‘keyTime[i]’ <= “23:59”
keyName.length == keyTime.length  == ‘N’

Where ‘T’ is the number of test cases, ‘N’ is the number of workers, ‘keyName[i]’  is the name of the ith worker,  and ‘keyTime[i]’ is the time of the ith worker.

Time Limit: 1 sec.
``````
Sample Input 1:
``````1
5
ninja ninja kevin ninja kevin
09:00 09:30 10:10 09:59 10:00
``````
Sample Output 1:
``````ninja
``````
Explanation for sample input 1:
``````“ninja” uses the ‘key-card’ more than two times in a one-hour period, i.e., at [“09:00”, “09:30”, “09:59”].
``````
Sample Input 2:
``````1
3
ninja ninja ninja
14:00 14:02 16:00
``````
Sample Output 2:
``````
``````
Explanation for sample input 2:
``````“ninja” did not use his ‘key-card’ more than two times in a one-hour. So, the output is the blank line.
``````
Console