FastPrepActive Users in the Last Five Minutes
Problems/Active Users in the Last Five Minutes

Active Users in the Last Five Minutes

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: Given log events of the form (time in seconds, user id, event type) in time order, the candidate had to keep, after each event, the number of distinct users seen during the five minutes ending at that event. The round was the first technical interview of an Adobe hiring drive, and the problem came as a written statement.

The written problem does not say whether an event exactly 5 minutes old still counts, how equal times behave, what form the report takes, or any limits. Here an event counts while it is less than 300 seconds old, times never decrease and may repeat, the count is reported after every event, and the event type is left out because it does not change the count. There are at most 3000 events. The examples are our own.

The judged task matches the report at about 85%.

An analytics component reads a stream of log events in time order. Event i happened at second timestamps[i] and was made by user userIds[i].

After each event, report how many different users are active: a user is active if at least one of their events so far happened less than 300 seconds (5 minutes) before the current event. In other words, an earlier event at second s counts while timestamps[i] - s < 300; an event exactly 300 seconds old no longer counts. The current event always counts.

Only events up to and including the current one are known; later events in the same second are not counted yet. Return one count per event, in order.

Function

activeUsers(timestamps: int[], userIds: int[]) → int[]

Examples

Example 1

timestamps = [0,100,250,299,300,650]userIds = [7,8,7,9,8,7]return = [1,2,2,3,3,1]

At time 299 the events at 0, 100, 250 and 299 are all less than 300 seconds old, so the users are 7, 8 and 9: 3. At time 300 the event at 0 is exactly 300 seconds old and has left the window; users 8, 7, 9 and 8 remain, so the count is still 3. At time 650 only the current event is in the window: 1.

Example 2

timestamps = [5,5,5]userIds = [1,1,2]return = [1,1,2]

All three events happen in the same second. After the second event user 1 is still the only user, and after the third the count is 2.

Example 3

timestamps = [42]userIds = [1000000]return = [1]

One event, one active user.

Constraints

  • 1 <= timestamps.length <= 3000 and userIds.length == timestamps.length
  • 0 <= timestamps[i] <= 10^6
  • timestamps never decreases (several events can share a second).
  • 1 <= userIds[i] <= 10^6

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
public int[] activeUsers(int[] timestamps, int[] userIds) {
    // Write your code here.
}
Checking account…