FastPrepTimed Message Batches
Problems/Timed Message Batches

Timed Message Batches

Adobe logoAdobe● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem groups timed messages into batches: the first message of a batch starts a timer, and when the timer fires the batch is logged and cleared. An Adobe Software Engineer entry (a Taro copy of a Glassdoor review) names only the kind of task set in its hiring-manager round, the first technical one: a timed message buffer that is flushed to a log. It gives no timing rule, input format or examples.

Our choices: the timer starts with each batch's first message (not a fixed clock), a message at the exact firing time starts the next batch, batches list messages oldest first, the input as lists of times and messages, at most 2000 messages, and new examples.

The judged task matches the report at about 55%.

A messaging service collects incoming messages into a batch. When a message arrives and no batch is open, it opens a new batch and starts a timer that fires window time units later. Every message that arrives before the timer fires joins that batch. When the timer fires, the service logs the batch and clears it. A message that arrives at exactly the firing time goes into a new batch.

Message i arrives at time times[i]. Return the logged batches in the order they are logged, each batch listing its messages in arrival order. Every batch is eventually logged, including the last one.

Function

timedBatches(times: int[], messages: String[], window: int) → List<List<String>>

Examples

Example 1

times = [3,6,9,14]messages = ["ping","pong","ack","done"]window = 5return = [["ping","pong"],["ack"],["done"]]

The first message at time 3 opens a batch that is logged at 3 + 5 = 8, so it holds ping and pong. ack at 9 opens the next batch, logged at 14. done arrives at 14, exactly when that batch is logged, so it starts a third batch.

Example 2

times = [0,4,4,8]messages = ["a1","b2","c3","d4"]window = 4return = [["a1"],["b2","c3"],["d4"]]

The batch opened at time 0 is logged at 4, before the two messages that arrive at 4, so it holds only a1. Those two open the next batch, logged at 8, and d4 at 8 starts a new one.

Example 3

times = [100]messages = ["solo"]window = 1return = [["solo"]]

One message, one batch, logged at time 101.

Constraints

  • 1 <= times.length <= 2000 and messages.length == times.length
  • 0 <= times[i] <= 10^9, and times never decreases
  • each message is 1 to 10 characters, lowercase letters or digits
  • 1 <= window <= 10^9

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 List<List<String>> timedBatches(int[] times, String[] messages, int window) {
    // Write your code here.
}
Checking account…