MediumArrayHash TableStringSortingUpdated Sep 2026

2933. High-Access Employees

Asked at Atlassian

Difficulty

Medium

Time

O(n log n)

Space

O(n)

Pattern

Array

Companies

1

Problem

You get a list of access records. Each record is a pair: an employee name and a time written as four digits in 24-hour format, like "0800" or "2250". All records happen on the same day.

An employee is called high-access if they opened the system 3 or more times inside one hour. In other words, some group of 3 of their accesses must all fit inside a window of 60 minutes or less.

Two details change the answer. First, a gap of exactly 60 minutes does not count as the same hour. So "0815" and "0915" are in different windows, but "0815" and "0914" are in the same one. Second, the day does not wrap around: "2350" and "0005" are never in the same window, even though they are only 15 minutes apart on a clock.

Return the names of all high-access employees. The order does not matter.

Three accesses inside one hour

a49 min053205490621012All three of a's accesses fit inside a 60-minutewindowb0457054001b has only two accesses, so no window can ever holdthree
Employee "a" has three accesses spanning 49 minutes, so "a" is high-access; "b" only has two accesses and cannot qualify.

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
  • ●access_times[i][1] consists only of '0' to '9'

Examples

Example 1
Inputaccess_times = [["a","0549"],["b","0457"],["a","0532"],["a","0621"],["b","0540"]]
Output["a"]
WhyEmployee "a" has accesses at 05:32, 05:49 and 06:21. The gap from 05:32 to 06:21 is 49 minutes, so all three fit in one hour — "a" qualifies. Employee "b" only has two accesses total, so they can never reach three.
Example 2
Inputaccess_times = [["d","0002"],["c","0808"],["c","0829"],["e","0215"],["d","1508"],["d","1444"],["d","1410"],["c","0809"]]
Output["c","d"]
Why"c" has 08:08, 08:09 and 08:29 — the span is 21 minutes, so "c" qualifies. "d" has 14:10, 14:44 and 15:08 — the span is 58 minutes, so "d" qualifies too. "e" has only one access, so "e" is out.
Example 3
Inputaccess_times = [["cd","1025"],["ab","1025"],["cd","1046"],["cd","1055"],["ab","1124"],["ab","1120"]]
Output["ab","cd"]
Why"ab" has 10:25, 11:20 and 11:24. The span from 10:25 to 11:24 is 59 minutes, which is still inside one hour, so "ab" qualifies. "cd" has 10:25, 10:46 and 10:55, a span of 30 minutes, so "cd" qualifies as well.

Asked At

1 companies
CompanyDifficulty
AtlassianMediumView all Atlassian questions →

How to Think About It

1

Group access times by username using a hash map

2

For each user, sort their access times and convert to numeric minutes

3

Use a sliding window to check if any 3 consecutive accesses fall within 60 minutes

4

For each pair of times separated by 2 positions, check if time[i+2] - time[i] <= 60

5

Collect all qualifying usernames and sort them for the final answer

Optimal Approach

Group all access times by username using a hash map. For each user, convert their time strings to numeric minutes and sort them. Use a sliding window of size 3: for each index i, check if times[i+2] - times[i] <= 60. If yes, this user accessed the system 3 times within a 60-minute window, so mark them as high-access. Collect all qualifying usernames and sort them alphabetically. The grouping step takes O(n) time, sorting each user times takes O(m log m) where m is per-user accesses, and the sliding window scan is O(m) per user. Overall complexity is O(n log n) dominated by sorting.

Sort, then slide a window of 3

a (minutes)332349381012ii+2Step 1 — convert to minutes and sort: 05:32 → 332,05:49 → 349, 06:21 → 381check times[i+2] − times[i] <= 60381 − 332 = 49 <= 60 → high-accessgroup times by nameconvert HHMM to minutessort each listscan window of 3collect namesThe full pipeline for every employee in the input
After sorting, it is enough to compare each access with the one two positions later.
ComplexityTime O(n log n)Space O(n)The cost comes from sorting each employee's access times; the hash map and the size-3 window scan are both linear.

What Trips People Up in Real Interviews

1

Convert "HHMM" string to integer minutes: int(time[:2]) * 60 + int(time[2:])

2

Clarify that the window is strictly less than 60 minutes or within 60 minutes

3

After grouping by user, the key insight is checking every 3rd element gap

4

Sorting users at the end is required for the output format

5

Edge case: user with exactly 2 accesses can never be high-access

Solution Code

O(n log n) time
def findHighAccessEmployees(access_times):
    from collections import defaultdict
    user_times = defaultdict(list)
    for name, time in access_times:
        user_times[name].append(int(time[:2]) * 60 + int(time[2:]))
    res = []
    for name, times in user_times.items():
        times.sort()
        for i in range(len(times) - 2):
            if times[i + 2] - times[i] <= 60:
                res.append(name)
                break
    res.sort()
    return res

Pro at DSA?

Test your skills with a real FAANG-style mock interview.

Start a Mock Interview →

Frequently Asked Questions

What is the High-Access Employees problem?

You are given an array of access times where each element is a string in the format "HHMM" representing a 24-hour time. A user is considered a high-access employee if they access the system at least 3 times within any 1-hour (60 minute) window. Return the sorted list of usernames who are high-access employees. This problem tests sliding window and time-based pattern detection.

How do you solve High-Access Employees?

The optimal approach runs in O(n log n) time and O(n) space. Scroll up to "Optimal Approach" for the step-by-step walkthrough, diagrams, and code in Python, C++ and Java.

What companies ask High-Access Employees?

High-Access Employees is asked at Atlassian. It is a medium difficulty problem.

What are common mistakes on High-Access Employees?
  • Convert "HHMM" string to integer minutes: int(time[:2]) * 60 + int(time[2:])
  • Clarify that the window is strictly less than 60 minutes or within 60 minutes
  • After grouping by user, the key insight is checking every 3rd element gap
  • Sorting users at the end is required for the output format
  • Edge case: user with exactly 2 accesses can never be high-access