High-Access Employees - Problem
You are given a 2D array of strings access_times of size n. For each i where 0 ≤ i ≤ n - 1, access_times[i][0] represents the name of an employee, and access_times[i][1] represents the access time of that employee in 24-hour format ("0800" or "2250").
An employee is high-access if they accessed the system three or more times within a one-hour period. Times with exactly one hour of difference are not part of the same one-hour period. For example, "0815" and "0915" are not part of the same one-hour period.
Return a list containing the names of high-access employees in any order.
Input & Output
Example 1 — Multiple Employees
$
Input:
access_times = [["a","0549"],["b","0457"],["a","0532"],["a","0621"],["b","0540"]]
›
Output:
["a"]
💡 Note:
Employee 'a' has access times at 0549 (9:49), 0532 (5:32), and 0621 (6:21). After sorting: 532, 549, 621. The span from 532 to 621 is 89 minutes, but 532 to 549 is 17 minutes and we need to check sliding windows. Times 532, 549, 621 span 89 minutes which is > 60, so not high-access based on this analysis.
Example 2 — Close Time Window
$
Input:
access_times = [["d","0002"],["c","0808"],["c","0829"],["e","0215"],["d","1508"],["d","1444"],["d","1410"],["c","0809"]]
›
Output:
["c","d"]
💡 Note:
Employee 'c' has times 808, 829, 809. Sorted: 808, 809, 829. Window 808-829 = 21 minutes with 3 accesses. Employee 'd' has times 0002, 1508, 1444, 1410. Sorted: 2, 1410, 1444, 1508. Window 1410-1508 = 58 minutes with 3 accesses.
Example 3 — No Violations
$
Input:
access_times = [["cd","0000"],["cd","0200"],["cd","0400"]]
›
Output:
[]
💡 Note:
Employee 'cd' has times 0000, 0200, 0400. These are spaced 120 minutes apart (0000 to 0200 = 120 min, 0200 to 0400 = 120 min), so no 3 accesses occur within 60 minutes.
Constraints
- 1 ≤ access_times.length ≤ 100
- access_times[i].length == 2
- 1 ≤ access_times[i][0].length ≤ 10
- access_times[i][0] consists only of English small letters
- access_times[i][1].length == 4
- access_times[i][1] is in 24-hour time format
Visualization
Tap to expand
Understanding the Visualization
1
Input Processing
Parse employee access records with timestamps
2
Pattern Detection
Find employees with 3+ accesses in <60 minutes
3
Result
List of high-access employees
Key Takeaway
🎯 Key Insight: Sort timestamps per employee, then use sliding window to efficiently detect violations
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code