#2933
Medium Algorithms High access employees
Array Hash Table String Sorting
47.3% acceptance
Feb 25, 2026
226
22
You are given a 2D 0-indexed array of strings, access_times, with size n.
For each i, access_times[i][0] represents the name of an employee, and access_times[i][1] represents
the access time of that employee. All entries in access_times are within the same day.
An employee is said to be high-access if he has accessed the system three or more times within a
one-hour period. Times with exactly one hour of difference are not considered part of the same period.
Return a list that contains the names of high-access employees with any order you want.
Solution
Rust
Time O(n²)
Space O(n)
impl Solution {
pub fn find_high_access_employees(access_times: Vec<Vec<String>>) -> Vec<String> {
let mut map: std::collections::HashMap<&str, Vec<i32>> = std::collections::HashMap::new();
for entry in &access_times {
let name = entry[0].as_str();
let t = &entry[1];
let mins = t[..2].parse::<i32>().unwrap() * 60 + t[2..].parse::<i32>().unwrap();
map.entry(name).or_default().push(mins);
}
let mut result = Vec::new();
for (name, mut times) in map {
times.sort_unstable();
let n = times.len();
if n >= 3 {
for i in 0..n - 2 {
if times[i + 2] - times[i] < 60 {
result.push(name.to_string());
break;
}
}
}
}
result
}
}